mirror of
https://github.com/xroche/httrack.git
synced 2026-05-17 16:36:07 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f8a15c76f |
@@ -134,7 +134,6 @@ am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -143,12 +142,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -162,7 +163,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -218,6 +218,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
241
compile
241
compile
@@ -1,10 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
# Wrapper for compilers which do not understand `-c -o'.
|
||||
|
||||
scriptversion=2012-03-05.13; # UTC
|
||||
scriptversion=2005-05-14.22
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
|
||||
# Software Foundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,7 +17,8 @@ scriptversion=2012-03-05.13; # UTC
|
||||
# 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/>.
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -29,219 +29,21 @@ scriptversion=2012-03-05.13; # UTC
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
Wrapper for compilers which do not understand `-c -o'.
|
||||
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
right script to run: please start by reading the file `INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
@@ -251,13 +53,11 @@ EOF
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
eat=
|
||||
|
||||
for arg
|
||||
do
|
||||
@@ -266,8 +66,8 @@ do
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
||||
# So we strip `-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
@@ -294,22 +94,22 @@ do
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# If no `-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# `.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# Note: use `[/.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
@@ -324,9 +124,9 @@ trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
@@ -338,6 +138,5 @@ exit $ret
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
||||
|
||||
@@ -42,10 +42,6 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 or 0, depending whether the compiler supports simple visibility
|
||||
declarations. */
|
||||
#undef HAVE_VISIBILITY
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
@@ -71,9 +67,6 @@
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
|
||||
64
configure.ac
64
configure.ac
@@ -1,32 +1,4 @@
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([httrack], [3.48.10], [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
|
||||
|
||||
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
|
||||
])
|
||||
|
||||
AC_INIT([httrack], [3.48.9], [roche+packaging@httrack.com], [httrack], [http://www.httrack.com/])
|
||||
AC_CONFIG_SRCDIR(src/httrack.c)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
@@ -34,12 +6,13 @@ AM_INIT_AUTOMAKE
|
||||
VERSION_INFO="2:48:0"
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PREREQ(2.50)
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
AC_STDC_HEADERS
|
||||
LT_INIT
|
||||
AC_PROG_LN_S
|
||||
AM_PROG_LIBTOOL
|
||||
|
||||
# Export LD_LIBRARY_PATH name or equivalent.
|
||||
AC_SUBST(SHLIBPATH_VAR,$shlibpath_var)
|
||||
@@ -47,33 +20,12 @@ AC_SUBST(SHLIBPATH_VAR,$shlibpath_var)
|
||||
# Export .libs or equivalent.
|
||||
AC_SUBST(LT_CV_OBJDIR,$lt_cv_objdir)
|
||||
|
||||
# Export version info
|
||||
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 \
|
||||
-Wpointer-arith -Wsequence-point -Wnested-externs \
|
||||
-D_REENTRANT"
|
||||
DEFAULT_CFLAGS="-Wall -Wcast-align -Wstrict-prototypes \
|
||||
-Wmissing-prototypes -Wmissing-declarations -Wpointer-arith \
|
||||
-Wnested-externs -D_REENTRANT"
|
||||
AC_SUBST(DEFAULT_CFLAGS)
|
||||
DEFAULT_LDFLAGS=""
|
||||
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([-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_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"])
|
||||
|
||||
### Check for -fvisibility=hidden support
|
||||
gl_VISIBILITY
|
||||
AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"
|
||||
AC_SUBST([AM_CFLAGS])
|
||||
AC_SUBST(VERSION_INFO)
|
||||
|
||||
### Check for platform
|
||||
#case $host in
|
||||
|
||||
6
debian/changelog
vendored
6
debian/changelog
vendored
@@ -1,9 +1,3 @@
|
||||
httrack (3.48.10) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.10 (3.48-10)
|
||||
|
||||
-- Xavier Roche <xavier@debian.org> Wed, 04 Jun 2014 19:00:07 +0200
|
||||
|
||||
httrack (3.48.9-1) unstable; urgency=low
|
||||
|
||||
* Updated to 3.48.9 (3.48-9)
|
||||
|
||||
4
debian/control
vendored
4
debian/control
vendored
@@ -3,10 +3,8 @@ Section: web
|
||||
Priority: optional
|
||||
Maintainer: Xavier Roche <roche@httrack.com>
|
||||
Standards-Version: 3.9.5
|
||||
Build-Depends: debhelper (>= 8.0.0), dh-autoreconf, autotools-dev, autoconf, autoconf-archive, automake, libtool, zlib1g-dev, libssl-dev
|
||||
Build-Depends: debhelper (>= 8.0.0), dh-autoreconf, autotools-dev, autoconf, automake, libtool, zlib1g-dev, libssl-dev
|
||||
Homepage: http://www.httrack.com
|
||||
Vcs-Svn: http://httrack.googlecode.com/svn/trunk
|
||||
Vcs-Browser: https://code.google.com/p/httrack/source/browse/trunk/src
|
||||
|
||||
Package: httrack
|
||||
Architecture: any
|
||||
|
||||
@@ -4,13 +4,7 @@ HTTrack Website Copier release history:
|
||||
|
||||
This file lists all changes and fixes that have been made for HTTrack.
|
||||
|
||||
3.48-10
|
||||
+ Fixed: injection-proof templates
|
||||
+ Fixed: htshash.c:330 assertion failure ("error invalidating hash entry") (Sergey)
|
||||
+ Fixed: Windows 2000 regression (fantozzi.usenet)
|
||||
+ Fixed: code cleanup (aliasing issues, const correctness, safe strings)
|
||||
+ New: handle --max-links 0 to disable maximum link limits
|
||||
+ New: updated ZIP routines (zlib 1.2.8)
|
||||
3.48-9
|
||||
+ Fixed: broken 32-bit version
|
||||
+ Fixed: assertion "segOutputSize < segSize assertion fails at htscharset.c:993"
|
||||
+ Fixed: new zlib version fixing CVE-2004-0797 and CVE-2005-2096
|
||||
|
||||
@@ -115,7 +115,6 @@ DATA = $(HelpHtml_DATA) $(HelpHtmlTxt_DATA) $(HelpHtmldiv_DATA) \
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -124,12 +123,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -143,7 +144,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -199,6 +199,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -104,7 +104,6 @@ DATA = $(lang_DATA) $(langroot_DATA)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -113,12 +112,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -132,7 +133,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -188,6 +188,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -201,7 +201,6 @@ CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -210,12 +209,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -229,7 +230,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -285,6 +285,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -74,7 +74,6 @@ am__can_run_installinfo = \
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -83,12 +82,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -102,7 +103,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -158,6 +158,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -105,7 +105,6 @@ MANS = $(man_MANS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -114,12 +113,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -133,7 +134,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -189,6 +189,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.\" Process this file with
|
||||
.\" groff -man -Tascii httrack.1
|
||||
.\"
|
||||
.TH httrack 1 "04 June 2014" "httrack website copier"
|
||||
.TH httrack 1 "15 May 2014" "httrack website copier"
|
||||
.SH NAME
|
||||
httrack \- offline browser : copy websites to a local directory
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -69,14 +69,9 @@ libhtsjava_la_LIBADD = $(THREADS_LIBS) $(DL_LIBS) libhttrack.la
|
||||
libhtsjava_la_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
|
||||
EXTRA_DIST = httrack.h webhttrack \
|
||||
minizip/ChangeLogUnzip \
|
||||
minizip/iowin32.c \
|
||||
minizip/iowin32.h \
|
||||
minizip/ioapi.c.diff \
|
||||
minizip/ioapi.h.diff \
|
||||
minizip/zip.c.diff \
|
||||
minizip/zip.h.diff \
|
||||
minizip/MiniZip64_Changes.txt \
|
||||
minizip/MiniZip64_info.txt \
|
||||
proxy/AUTHORS \
|
||||
proxy/COPYING \
|
||||
proxy/changelog.txt \
|
||||
|
||||
@@ -179,7 +179,6 @@ CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -188,12 +187,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -207,7 +208,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -263,6 +263,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
@@ -374,14 +375,9 @@ 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 \
|
||||
minizip/ChangeLogUnzip \
|
||||
minizip/iowin32.c \
|
||||
minizip/iowin32.h \
|
||||
minizip/ioapi.c.diff \
|
||||
minizip/ioapi.h.diff \
|
||||
minizip/zip.c.diff \
|
||||
minizip/zip.h.diff \
|
||||
minizip/MiniZip64_Changes.txt \
|
||||
minizip/MiniZip64_info.txt \
|
||||
proxy/AUTHORS \
|
||||
proxy/COPYING \
|
||||
proxy/changelog.txt \
|
||||
|
||||
@@ -189,10 +189,10 @@ const char *hts_optalias[][4] = {
|
||||
/* Badly documented */
|
||||
{"debug-testfilters", "-#0", "param1", "debug: test filters"},
|
||||
{"advanced-flushlogs", "-#f", "single", ""},
|
||||
{"advanced-maxfilters", "-#F", "param", "maximum number of scan rules"},
|
||||
{"advanced-maxfilters", "-#F", "param", ""},
|
||||
{"version", "-#h", "single", ""},
|
||||
{"debug-scanstdin", "-#K", "single", ""},
|
||||
{"advanced-maxlinks", "-#L", "single", "maximum number of links (0 to disable limit)"},
|
||||
{"advanced-maxlinks", "-#L", "single", ""},
|
||||
{"advanced-progressinfo", "-#p", "single", "deprecated"},
|
||||
{"catch-url", "-#P", "single", "catch complex URL through proxy"},
|
||||
/*{"debug-oldftp","-#R","single",""}, */
|
||||
@@ -560,8 +560,8 @@ int optinclude_file(const char *name, int *argc, char **argv, char *x_argvblk,
|
||||
|
||||
/* Get home directory, '.' if failed */
|
||||
/* example: /home/smith */
|
||||
const char *hts_gethome(void) {
|
||||
const char *home = getenv("HOME");
|
||||
char *hts_gethome(void) {
|
||||
char *home = getenv("HOME");
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
|
||||
@@ -48,7 +48,7 @@ const char *optreal_value(int p);
|
||||
const char *optalias_value(int p);
|
||||
const char *opttype_value(int p);
|
||||
const char *opthelp_value(int p);
|
||||
const char *hts_gethome(void);
|
||||
char *hts_gethome(void);
|
||||
void expand_home(String * str);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) {
|
||||
|
||||
while((item = inthash_enum_next(&e))) {
|
||||
#ifndef HTS_NO_BACK_ON_DISK
|
||||
const char *filename = (char *) item->value.ptr;
|
||||
char *filename = (char *) item->value.ptr;
|
||||
|
||||
if (filename != NULL) {
|
||||
(void) UNLINK(filename);
|
||||
@@ -139,19 +139,19 @@ void back_delete_all(httrackp * opt, cache_back * cache, struct_back * sback) {
|
||||
// ---
|
||||
// routines de backing
|
||||
|
||||
static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr,
|
||||
const char *fil, const char *sav, int getIndex);
|
||||
static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr,
|
||||
const char *fil, const char *sav, int getIndex);
|
||||
static int back_index_ready(httrackp * opt, struct_back * sback, char *adr,
|
||||
char *fil, char *sav, int getIndex);
|
||||
static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr,
|
||||
char *fil, char *sav, int getIndex);
|
||||
|
||||
// retourne l'index d'un lien dans un tableau de backing
|
||||
int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil,
|
||||
const char *sav) {
|
||||
int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil,
|
||||
char *sav) {
|
||||
return back_index_fetch(opt, sback, adr, fil, sav, 1);
|
||||
}
|
||||
|
||||
static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr,
|
||||
const char *fil, const char *sav, int getIndex) {
|
||||
static int back_index_fetch(httrackp * opt, struct_back * sback, char *adr,
|
||||
char *fil, char *sav, int getIndex) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int index = -1;
|
||||
@@ -177,8 +177,8 @@ static int back_index_fetch(httrackp * opt, struct_back * sback, const char *adr
|
||||
}
|
||||
|
||||
/* resurrect stored entry */
|
||||
static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr,
|
||||
const char *fil, const char *sav, int getIndex) {
|
||||
static int back_index_ready(httrackp * opt, struct_back * sback, char *adr,
|
||||
char *fil, char *sav, int getIndex) {
|
||||
lien_back *const back = sback->lnk;
|
||||
void *ptr = NULL;
|
||||
|
||||
@@ -194,7 +194,7 @@ static int back_index_ready(httrackp * opt, struct_back * sback, const char *adr
|
||||
|
||||
#ifndef HTS_NO_BACK_ON_DISK
|
||||
FILE *fp;
|
||||
const char *fileback = (char *) ptr;
|
||||
char *fileback = (char *) ptr;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
if ((fp = FOPEN(fconv(catbuff, sizeof(catbuff), fileback), "rb")) != NULL) {
|
||||
@@ -349,8 +349,8 @@ int back_cleanup_background(httrackp * opt, cache_back * cache,
|
||||
}
|
||||
|
||||
// nombre d'entrées libres dans le backing
|
||||
int back_available(const struct_back * sback) {
|
||||
const lien_back *const back = sback->lnk;
|
||||
int back_available(struct_back * sback) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int i;
|
||||
int nb = 0;
|
||||
@@ -362,8 +362,8 @@ int back_available(const struct_back * sback) {
|
||||
}
|
||||
|
||||
// retourne estimation de la taille des html et fichiers stockés en mémoire
|
||||
LLint back_incache(const struct_back * sback) {
|
||||
const lien_back *const back = sback->lnk;
|
||||
LLint back_incache(struct_back * sback) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int i;
|
||||
LLint sum = 0;
|
||||
@@ -391,8 +391,8 @@ LLint back_incache(const struct_back * sback) {
|
||||
}
|
||||
|
||||
// retourne estimation de la taille des html et fichiers stockés en mémoire
|
||||
int back_done_incache(const struct_back * sback) {
|
||||
const lien_back *const back = sback->lnk;
|
||||
int back_done_incache(struct_back * sback) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int i;
|
||||
int n = 0;
|
||||
@@ -420,14 +420,14 @@ int back_done_incache(const struct_back * sback) {
|
||||
}
|
||||
|
||||
// le lien a-t-il été mis en backing?
|
||||
HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr,
|
||||
const char *fil, const char *sav) {
|
||||
HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr,
|
||||
char *fil, char *sav) {
|
||||
return (back_index_fetch(opt, sback, adr, fil, sav, /*don't fetch */ 0) >= 0);
|
||||
}
|
||||
|
||||
// nombre de sockets en tâche de fond
|
||||
int back_nsoc(const struct_back * sback) {
|
||||
const lien_back *const back = sback->lnk;
|
||||
int back_nsoc(struct_back * sback) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int n = 0;
|
||||
int i;
|
||||
@@ -438,8 +438,8 @@ int back_nsoc(const struct_back * sback) {
|
||||
|
||||
return n;
|
||||
}
|
||||
int back_nsoc_overall(const struct_back * sback) {
|
||||
const lien_back *const back = sback->lnk;
|
||||
int back_nsoc_overall(struct_back * sback) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int n = 0;
|
||||
int i;
|
||||
@@ -515,7 +515,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
&& (back[p].r.statuscode > 0) // not internal error
|
||||
) {
|
||||
if (!back[p].testmode) { // not test mode
|
||||
const char *state = "unknown";
|
||||
char *state = "unknown";
|
||||
|
||||
/* décompression */
|
||||
#if HTS_USEZLIB
|
||||
@@ -626,7 +626,7 @@ int back_finalize(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
FILE *fp = FOPEN(back[p].url_sav, "rb");
|
||||
|
||||
if (fp) {
|
||||
back[p].r.adr = malloct((size_t) sz + 1);
|
||||
back[p].r.adr = malloct((int) sz + 2);
|
||||
if (back[p].r.adr) {
|
||||
if (fread(back[p].r.adr, 1, sz, fp) == sz) {
|
||||
back[p].r.size = sz;
|
||||
@@ -980,7 +980,7 @@ int back_unserialize(FILE * fp, lien_back ** dst) {
|
||||
/* serialize a reference ; used to store references of files being downloaded in case of broken download */
|
||||
/* Note: NOT utf-8 */
|
||||
int back_serialize_ref(httrackp * opt, const lien_back * src) {
|
||||
const char *filename =
|
||||
char *filename =
|
||||
url_savename_refname_fullpath(opt, src->url_adr, src->url_fil);
|
||||
FILE *fp = fopen(filename, "wb");
|
||||
|
||||
@@ -1012,7 +1012,7 @@ int back_serialize_ref(httrackp * opt, const lien_back * src) {
|
||||
/* unserialize a reference ; used to store references of files being downloaded in case of broken download */
|
||||
int back_unserialize_ref(httrackp * opt, const char *adr, const char *fil,
|
||||
lien_back ** dst) {
|
||||
const char *filename = url_savename_refname_fullpath(opt, adr, fil);
|
||||
char *filename = url_savename_refname_fullpath(opt, adr, fil);
|
||||
FILE *fp = FOPEN(filename, "rb");
|
||||
|
||||
if (fp != NULL) {
|
||||
@@ -1148,7 +1148,7 @@ int back_trylive(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
}
|
||||
|
||||
/* search for a live position, or, if not possible, try to return a new one */
|
||||
int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr) {
|
||||
int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
int i;
|
||||
@@ -1400,8 +1400,8 @@ int back_stack_available(struct_back * sback) {
|
||||
|
||||
// ajouter un lien en backing
|
||||
int back_add_if_not_exists(struct_back * sback, httrackp * opt,
|
||||
cache_back * cache, const char *adr, const char *fil, const char *save,
|
||||
const char *referer_adr, const char *referer_fil, int test) {
|
||||
cache_back * cache, char *adr, char *fil, char *save,
|
||||
char *referer_adr, char *referer_fil, int test) {
|
||||
back_clean(opt, cache, sback); /* first cleanup the backlog to ensure that we have some entry left */
|
||||
if (!back_exist(sback, opt, adr, fil, save)) {
|
||||
return back_add(sback, opt, cache, adr, fil, save, referer_adr, referer_fil,
|
||||
@@ -1410,8 +1410,8 @@ int back_add_if_not_exists(struct_back * sback, httrackp * opt,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr,
|
||||
const char *fil, const char *save, const char *referer_adr, const char *referer_fil,
|
||||
int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr,
|
||||
char *fil, char *save, char *referer_adr, char *referer_fil,
|
||||
int test) {
|
||||
lien_back *const back = sback->lnk;
|
||||
const int back_max = sback->count;
|
||||
@@ -1974,7 +1974,7 @@ int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char
|
||||
printf("ok, dns cache ready..\n");
|
||||
#endif
|
||||
soc =
|
||||
http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &back[p].r);
|
||||
http_xfopen(opt, 0, 0, 0, back[p].send_too, adr, fil, &(back[p].r));
|
||||
if (soc == INVALID_SOCKET) {
|
||||
back[p].status = STATUS_READY; // fini, erreur
|
||||
back_set_finished(sback, p);
|
||||
|
||||
@@ -74,21 +74,21 @@ void back_free(struct_back ** sback);
|
||||
// backing
|
||||
#define BACK_ADD_TEST "(dummy)"
|
||||
#define BACK_ADD_TEST2 "(dummy2)"
|
||||
int back_index(httrackp * opt, struct_back * sback, const char *adr, const char *fil,
|
||||
const char *sav);
|
||||
int back_available(const struct_back * sback);
|
||||
LLint back_incache(const struct_back * sback);
|
||||
int back_done_incache(const struct_back * sback);
|
||||
HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, const char *adr,
|
||||
const char *fil, const char *sav);
|
||||
int back_nsoc(const struct_back * sback);
|
||||
int back_nsoc_overall(const struct_back * sback);
|
||||
int back_add(struct_back * sback, httrackp * opt, cache_back * cache, const char *adr,
|
||||
const char *fil, const char *save, const char *referer_adr, const char *referer_fil,
|
||||
int back_index(httrackp * opt, struct_back * sback, char *adr, char *fil,
|
||||
char *sav);
|
||||
int back_available(struct_back * sback);
|
||||
LLint back_incache(struct_back * sback);
|
||||
int back_done_incache(struct_back * sback);
|
||||
HTS_INLINE int back_exist(struct_back * sback, httrackp * opt, char *adr,
|
||||
char *fil, char *sav);
|
||||
int back_nsoc(struct_back * sback);
|
||||
int back_nsoc_overall(struct_back * sback);
|
||||
int back_add(struct_back * sback, httrackp * opt, cache_back * cache, char *adr,
|
||||
char *fil, char *save, char *referer_adr, char *referer_fil,
|
||||
int test);
|
||||
int back_add_if_not_exists(struct_back * sback, httrackp * opt,
|
||||
cache_back * cache, const char *adr, const char *fil, const char *save,
|
||||
const char *referer_adr, const char *referer_fil, int test);
|
||||
cache_back * cache, char *adr, char *fil, char *save,
|
||||
char *referer_adr, char *referer_fil, int test);
|
||||
int back_stack_available(struct_back * sback);
|
||||
int back_search(httrackp * opt, struct_back * sback);
|
||||
int back_search_quick(struct_back * sback);
|
||||
@@ -99,7 +99,7 @@ void back_wait(struct_back * sback, httrackp * opt, cache_back * cache,
|
||||
TStamp stat_timestart);
|
||||
int back_letlive(httrackp * opt, cache_back * cache, struct_back * sback,
|
||||
const int p);
|
||||
int back_searchlive(httrackp * opt, struct_back * sback, const char *search_addr);
|
||||
int back_searchlive(httrackp * opt, struct_back * sback, char *search_addr);
|
||||
void back_connxfr(htsblk * src, htsblk * dst);
|
||||
void back_move(lien_back * src, lien_back * dst);
|
||||
void back_copy_static(const lien_back * src, lien_back * dst);
|
||||
|
||||
@@ -38,15 +38,14 @@ Please visit our Website: http://www.httrack.com
|
||||
/* specific definitions */
|
||||
#include "htsglobal.h"
|
||||
#include "htslib.h"
|
||||
#include "htscore.h"
|
||||
|
||||
/* END specific definitions */
|
||||
|
||||
// gestion des cookie
|
||||
// ajoute, dans l'ordre
|
||||
// !=0 : erreur
|
||||
int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value,
|
||||
const char *domain, const char *path) {
|
||||
int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value,
|
||||
char *domain, char *path) {
|
||||
char buffer[8192];
|
||||
char *a = cookie->data;
|
||||
char *insert;
|
||||
@@ -54,20 +53,20 @@ int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value,
|
||||
|
||||
// effacer éventuel cookie en double
|
||||
cookie_del(cookie, cook_name, domain, path);
|
||||
if (strlen(cook_value) > 1024)
|
||||
if ((int) strlen(cook_value) > 1024)
|
||||
return -1; // trop long
|
||||
if (strlen(cook_name) > 256)
|
||||
if ((int) strlen(cook_name) > 256)
|
||||
return -1; // trop long
|
||||
if (strlen(domain) > 256)
|
||||
if ((int) strlen(domain) > 256)
|
||||
return -1; // trop long
|
||||
if (strlen(path) > 256)
|
||||
if ((int) strlen(path) > 256)
|
||||
return -1; // trop long
|
||||
if (strlen(cookie->data)
|
||||
if ((int) (strlen(cookie->data)
|
||||
+ strlen(cook_value)
|
||||
+ strlen(cook_name)
|
||||
+ strlen(domain)
|
||||
+ strlen(path)
|
||||
+ 256 > cookie->max_len)
|
||||
+ 256) > cookie->max_len)
|
||||
return -1; // impossible d'ajouter
|
||||
|
||||
insert = a; // insérer ici
|
||||
@@ -100,7 +99,7 @@ int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value,
|
||||
strcatbuff(cook, "\t");
|
||||
strcatbuff(cook, cook_value);
|
||||
strcatbuff(cook, "\n");
|
||||
if (!((strlen(cookie->data) + strlen(cook)) < cookie->max_len))
|
||||
if (!(((int) strlen(cookie->data) + (int) strlen(cook)) < cookie->max_len))
|
||||
return -1; // impossible d'ajouter
|
||||
cookie_insert(insert, cook);
|
||||
#if DEBUG_COOK
|
||||
@@ -112,13 +111,13 @@ int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value,
|
||||
}
|
||||
|
||||
// effacer cookie si existe
|
||||
int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path) {
|
||||
int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path) {
|
||||
char *a, *b;
|
||||
|
||||
b = cookie_find(cookie->data, cook_name, domain, path);
|
||||
if (b) {
|
||||
a = cookie_nextfield(b);
|
||||
cookie_delete(b, a - b);
|
||||
cookie_delete(b, (int) (a - b));
|
||||
#if DEBUG_COOK
|
||||
printf("deleted old cookie: %s %s %s\n", cook_name, domain, path);
|
||||
#endif
|
||||
@@ -129,7 +128,7 @@ int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, con
|
||||
// Matches wildcard cookie domains that start with a dot
|
||||
// chk_dom: the domain stored in the cookie (potentially wildcard).
|
||||
// domain: query domain
|
||||
static int cookie_cmp_wildcard_domain(const char *chk_dom, const char *domain) {
|
||||
static int cookie_cmp_wildcard_domain(char *chk_dom, char *domain) {
|
||||
const size_t n = strlen(chk_dom);
|
||||
const size_t m = strlen(domain);
|
||||
const size_t l = n < m ? n : m;
|
||||
@@ -153,7 +152,7 @@ static int cookie_cmp_wildcard_domain(const char *chk_dom, const char *domain) {
|
||||
// renvoie pointeur sur ligne, ou NULL si introuvable
|
||||
// path est aligné à droite et cook_name peut être vide (chercher alors tout cookie)
|
||||
// .doubleclick.net TRUE / FALSE 1999999999 id A
|
||||
char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path) {
|
||||
char *cookie_find(char *s, char *cook_name, char *domain, char *path) {
|
||||
char buffer[8192];
|
||||
char *a = s;
|
||||
|
||||
@@ -166,15 +165,15 @@ char *cookie_find(char *s, const char *cook_name, const char *domain, const char
|
||||
t = (strcmp(cookie_get(buffer, a, 5), cook_name) == 0); // tester si même nom
|
||||
if (t) { // même nom ou nom qualconque
|
||||
//
|
||||
const char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie
|
||||
char *chk_dom = cookie_get(buffer, a, 0); // domaine concerné par le cookie
|
||||
|
||||
if ((strlen(chk_dom) <= strlen(domain) &&
|
||||
if (((int) strlen(chk_dom) <= (int) strlen(domain) &&
|
||||
strcmp(chk_dom, domain + strlen(domain) - strlen(chk_dom)) == 0) ||
|
||||
!cookie_cmp_wildcard_domain(chk_dom, domain)) { // même domaine
|
||||
//
|
||||
const char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie
|
||||
char *chk_path = cookie_get(buffer, a, 2); // chemin concerné par le cookie
|
||||
|
||||
if (strlen(chk_path) <= strlen(path)) {
|
||||
if ((int) strlen(chk_path) <= (int) strlen(path)) {
|
||||
if (strncmp(path, chk_path, strlen(chk_path)) == 0) { // même chemin
|
||||
return a;
|
||||
}
|
||||
@@ -232,14 +231,15 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) {
|
||||
char dummy[512];
|
||||
|
||||
//
|
||||
lien_adrfil af; // chemin (/)
|
||||
char domain[256]; // domaine cookie (.netscape.com)
|
||||
char path[256]; // chemin (/)
|
||||
int cookie_merged = 0;
|
||||
|
||||
//
|
||||
// Read all cookies
|
||||
while(!feof(fp)) {
|
||||
cook_name[0] = cook_value[0] = domainpathpath[0]
|
||||
= dummy[0] = af.adr[0] = af.fil[0] = '\0';
|
||||
= dummy[0] = domain[0] = path[0] = '\0';
|
||||
linput(fp, cook_name, 250);
|
||||
if (!feof(fp)) {
|
||||
linput(fp, cook_value, 250);
|
||||
@@ -254,8 +254,8 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) {
|
||||
if (strnotempty(cook_name)
|
||||
&& strnotempty(cook_value)
|
||||
&& strnotempty(domainpathpath)) {
|
||||
if (ident_url_absolute(domainpathpath, &af) >= 0) {
|
||||
cookie_add(cookie, cook_name, cook_value, af.adr, af.fil);
|
||||
if (ident_url_absolute(domainpathpath, domain, path) >= 0) {
|
||||
cookie_add(cookie, cook_name, cook_value, domain, path);
|
||||
cookie_merged = 1;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ int cookie_load(t_cookie * cookie, const char *fpath, const char *name) {
|
||||
|
||||
// écrire cookies.txt
|
||||
// !=0 : erreur
|
||||
int cookie_save(t_cookie * cookie, const char *name) {
|
||||
int cookie_save(t_cookie * cookie, char *name) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
if (strnotempty(cookie->data)) {
|
||||
@@ -337,13 +337,13 @@ int cookie_save(t_cookie * cookie, const char *name) {
|
||||
}
|
||||
|
||||
// insertion chaine ins avant s
|
||||
void cookie_insert(char *s, const char *ins) {
|
||||
void cookie_insert(char *s, char *ins) {
|
||||
char *buff;
|
||||
|
||||
if (strnotempty(s) == 0) { // rien à faire, juste concat
|
||||
strcatbuff(s, ins);
|
||||
} else {
|
||||
buff = (char *) malloct(strlen(s) + 1);
|
||||
buff = (char *) malloct(strlen(s) + 2);
|
||||
if (buff) {
|
||||
strcpybuff(buff, s); // copie temporaire
|
||||
strcpybuff(s, ins); // insérer
|
||||
@@ -354,13 +354,13 @@ void cookie_insert(char *s, const char *ins) {
|
||||
}
|
||||
|
||||
// destruction chaine dans s position pos
|
||||
void cookie_delete(char *s, size_t pos) {
|
||||
void cookie_delete(char *s, int pos) {
|
||||
char *buff;
|
||||
|
||||
if (strnotempty(s + pos) == 0) { // rien à faire, effacer
|
||||
s[0] = '\0';
|
||||
} else {
|
||||
buff = (char *) malloct(strlen(s + pos) + 1);
|
||||
buff = (char *) malloct(strlen(s + pos) + 2);
|
||||
if (buff) {
|
||||
strcpybuff(buff, s + pos); // copie temporaire
|
||||
strcpybuff(s, buff); // copier
|
||||
@@ -371,8 +371,8 @@ void cookie_delete(char *s, size_t pos) {
|
||||
|
||||
// renvoie champ param de la chaine cookie_base
|
||||
// ex: cookie_get("ceci est<tab>un<tab>exemple",1) renvoi "un"
|
||||
const char *cookie_get(char *buffer, const char *cookie_base, int param) {
|
||||
const char *limit;
|
||||
char *cookie_get(char *buffer, char *cookie_base, int param) {
|
||||
char *limit;
|
||||
|
||||
while(*cookie_base == '\n')
|
||||
cookie_base++;
|
||||
@@ -393,7 +393,7 @@ const char *cookie_get(char *buffer, const char *cookie_base, int param) {
|
||||
}
|
||||
if (cookie_base) {
|
||||
if (cookie_base < limit) {
|
||||
const char *a = cookie_base;
|
||||
char *a = cookie_base;
|
||||
|
||||
while((*a) && (*a != '\t') && (*a != '\n'))
|
||||
a++;
|
||||
@@ -413,7 +413,7 @@ const char *cookie_get(char *buffer, const char *cookie_base, int param) {
|
||||
// -- basic auth --
|
||||
|
||||
/* déclarer un répertoire comme possédant une authentification propre */
|
||||
int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth) {
|
||||
int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth) {
|
||||
char buffer[HTS_URLMAXSIZE * 2];
|
||||
|
||||
if (cookie) {
|
||||
@@ -439,7 +439,7 @@ int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *a
|
||||
|
||||
/* tester adr et fil, et retourner authentification si nécessaire */
|
||||
/* sinon, retourne NULL */
|
||||
char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) {
|
||||
char *bauth_check(t_cookie * cookie, char *adr, char *fil) {
|
||||
char buffer[HTS_URLMAXSIZE * 2];
|
||||
|
||||
if (cookie) {
|
||||
@@ -458,7 +458,7 @@ char *bauth_check(t_cookie * cookie, const char *adr, const char *fil) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *bauth_prefix(char *prefix, const char *adr, const char *fil) {
|
||||
char *bauth_prefix(char *prefix, char *adr, char *fil) {
|
||||
char *a;
|
||||
|
||||
strcpybuff(prefix, jump_identification(adr));
|
||||
|
||||
@@ -34,8 +34,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#ifndef HTSBAUTH_DEFH
|
||||
#define HTSBAUTH_DEFH
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
// robots wizard
|
||||
#ifndef HTS_DEF_FWSTRUCT_bauth_chain
|
||||
#define HTS_DEF_FWSTRUCT_bauth_chain
|
||||
@@ -62,21 +60,21 @@ struct t_cookie {
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
|
||||
// cookies
|
||||
int cookie_add(t_cookie * cookie, const char *cook_name, const char *cook_value,
|
||||
const char *domain, const char *path);
|
||||
int cookie_del(t_cookie * cookie, const char *cook_name, const char *domain, const char *path);
|
||||
int cookie_add(t_cookie * cookie, char *cook_name, char *cook_value,
|
||||
char *domain, char *path);
|
||||
int cookie_del(t_cookie * cookie, char *cook_name, char *domain, char *path);
|
||||
int cookie_load(t_cookie * cookie, const char *path, const char *name);
|
||||
int cookie_save(t_cookie * cookie, const char *name);
|
||||
void cookie_insert(char *s, const char *ins);
|
||||
void cookie_delete(char *s, size_t pos);
|
||||
const char *cookie_get(char *buffer, const char *cookie_base, int param);
|
||||
char *cookie_find(char *s, const char *cook_name, const char *domain, const char *path);
|
||||
int cookie_save(t_cookie * cookie, char *name);
|
||||
void cookie_insert(char *s, char *ins);
|
||||
void cookie_delete(char *s, int pos);
|
||||
char *cookie_get(char *buffer, char *cookie_base, int param);
|
||||
char *cookie_find(char *s, char *cook_name, char *domain, char *path);
|
||||
char *cookie_nextfield(char *a);
|
||||
|
||||
// basic auth
|
||||
int bauth_add(t_cookie * cookie, const char *adr, const char *fil, const char *auth);
|
||||
char *bauth_check(t_cookie * cookie, const char *adr, const char *fil);
|
||||
char *bauth_prefix(char *buffer, const char *adr, const char *fil);
|
||||
int bauth_add(t_cookie * cookie, char *adr, char *fil, char *auth);
|
||||
char *bauth_check(t_cookie * cookie, char *adr, char *fil);
|
||||
char *bauth_prefix(char *buffer, char *adr, char *fil);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2016,12 +2016,12 @@ void cache_init(cache_back * cache, httrackp * opt) {
|
||||
|
||||
// lire un fichier.. (compatible \0)
|
||||
/* Note: NOT utf-8 */
|
||||
char *readfile(const char *fil) {
|
||||
char *readfile(char *fil) {
|
||||
return readfile2(fil, NULL);
|
||||
}
|
||||
|
||||
/* Note: NOT utf-8 */
|
||||
char *readfile2(const char *fil, LLint * size) {
|
||||
char *readfile2(char *fil, LLint * size) {
|
||||
char *adr = NULL;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
INTsys len = 0;
|
||||
@@ -2049,7 +2049,7 @@ char *readfile2(const char *fil, LLint * size) {
|
||||
}
|
||||
|
||||
/* Note: utf-8 */
|
||||
char *readfile_utf8(const char *fil) {
|
||||
char *readfile_utf8(char *fil) {
|
||||
char *adr = NULL;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
const off_t len = fsize_utf8(fil);
|
||||
@@ -2074,8 +2074,8 @@ char *readfile_utf8(const char *fil) {
|
||||
}
|
||||
|
||||
/* Note: NOT utf-8 */
|
||||
char *readfile_or(const char *fil, const char *defaultdata) {
|
||||
const char *realfile = fil;
|
||||
char *readfile_or(char *fil, char *defaultdata) {
|
||||
char *realfile = fil;
|
||||
char *ret;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
@@ -2085,7 +2085,7 @@ char *readfile_or(const char *fil, const char *defaultdata) {
|
||||
if (ret)
|
||||
return ret;
|
||||
else {
|
||||
char *adr = malloct(strlen(defaultdata) + 1);
|
||||
char *adr = malloct(strlen(defaultdata) + 2);
|
||||
|
||||
if (adr) {
|
||||
strcpybuff(adr, defaultdata);
|
||||
|
||||
@@ -40,7 +40,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsbase.h"
|
||||
#include "htsnet.h"
|
||||
#include "htslib.h"
|
||||
#include "htscore.h"
|
||||
#include <fcntl.h>
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
@@ -175,20 +174,21 @@ HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) {
|
||||
socinput(soc, line, 1000);
|
||||
if (strnotempty(line)) {
|
||||
if (sscanf(line, "%s %s %s", method, url, protocol) == 3) {
|
||||
lien_adrfil af;
|
||||
char BIGSTK url_adr[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK url_fil[HTS_URLMAXSIZE * 2];
|
||||
|
||||
// méthode en majuscule
|
||||
size_t i;
|
||||
int r = 0;
|
||||
|
||||
af.adr[0] = af.fil[0] = '\0';
|
||||
url_adr[0] = url_fil[0] = '\0';
|
||||
//
|
||||
for(i = 0; method[i] != '\0'; i++) {
|
||||
if ((method[i] >= 'a') && (method[i] <= 'z'))
|
||||
method[i] -= ('a' - 'A');
|
||||
}
|
||||
// adresse du lien
|
||||
if (ident_url_absolute(url, &af) >= 0) {
|
||||
if (ident_url_absolute(url, url_adr, url_fil) >= 0) {
|
||||
// Traitement des en-têtes
|
||||
char BIGSTK loc[HTS_URLMAXSIZE * 2];
|
||||
htsblk blkretour;
|
||||
@@ -197,7 +197,7 @@ HTSEXT_API int catch_url(T_SOC soc, char *url, char *method, char *data) {
|
||||
//memset(&blkretour, 0, sizeof(htsblk)); // effacer
|
||||
blkretour.location = loc; // si non nul, contiendra l'adresse véritable en cas de moved xx
|
||||
// Lire en têtes restants
|
||||
sprintf(data, "%s %s %s\r\n", method, af.fil, protocol);
|
||||
sprintf(data, "%s %s %s\r\n", method, url_fil, protocol);
|
||||
while(strnotempty(line)) {
|
||||
socinput(soc, line, 1000);
|
||||
treathead(NULL, NULL, NULL, &blkretour, line); // traiter
|
||||
|
||||
@@ -723,21 +723,43 @@ static unsigned int nlz8(unsigned char x) {
|
||||
26 U+200000 U+3FFFFFF 5 111110xx
|
||||
31 U+4000000 U+7FFFFFFF 6 1111110x
|
||||
*/
|
||||
#define ADD_FIRST_SEQ(UC, LEN, EMITTER) do { \
|
||||
/* first octet */ \
|
||||
const unsigned char lead = \
|
||||
/* leading bits: LEN "1" bits */ \
|
||||
~ ( ( 1 << (unsigned) ( 8 - LEN ) ) - 1 ) \
|
||||
/* encoded bits */ \
|
||||
| ( (UC) >> (unsigned) ( ( LEN - 1 ) * 6 ) ); \
|
||||
EMITTER(lead); \
|
||||
} while(0)
|
||||
|
||||
#define ADD_NEXT_SEQ(UC, SHIFT, EMITTER) do { \
|
||||
/* further bytes are encoding 6 bits */ \
|
||||
const unsigned char next = \
|
||||
0x80 | ( ( (UC) >> SHIFT ) & 0x3f ); \
|
||||
EMITTER(next); \
|
||||
#define ADD_SEQ(UC, BITS, EMITTER) do { \
|
||||
/* number of data bits in first octet */ \
|
||||
const unsigned int bits = BITS % 6; \
|
||||
/* shift for first octet */ \
|
||||
const unsigned int shift0 = BITS - bits; \
|
||||
/* first octet */ \
|
||||
const unsigned char lead = \
|
||||
/* leading bits */ \
|
||||
( 0xff ^ ( ( 1 << ( bits + 1 ) ) - 1 ) ) \
|
||||
/* encoded bits */ \
|
||||
| ( ( (UC) >> shift0 ) & ( ( 1 << ( bits + 1 ) ) - 1 ) ) \
|
||||
; \
|
||||
/* further bytes are encoding 6 bits */ \
|
||||
const unsigned char second = \
|
||||
0x80 | ( ( (UC) >> ( shift0 - 6 ) ) & 0x3f ); \
|
||||
EMITTER(lead); \
|
||||
EMITTER(second); \
|
||||
if (BITS > 6*2) { \
|
||||
const unsigned char next = \
|
||||
0x80 | ( ( (UC) >> ( shift0 - 6*2 ) ) & 0x3f ); \
|
||||
EMITTER(next); \
|
||||
if (BITS > 6*3) { \
|
||||
const unsigned char next = \
|
||||
0x80 | ( ( (UC) >> ( shift0 - 6*3 ) ) & 0x3f ); \
|
||||
EMITTER(next); \
|
||||
if (BITS > 6*4) { \
|
||||
const unsigned char next = \
|
||||
0x80 | ( ( (UC) >> ( shift0 - 6*4 ) ) & 0x3f ); \
|
||||
EMITTER(next); \
|
||||
if (BITS > 6*5) { \
|
||||
const unsigned char next = \
|
||||
0x80 | ( ( (UC) >> ( shift0 - 6*5 ) ) & 0x3f ); \
|
||||
EMITTER(next); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* UC is a constant. EMITTER is a macro function taking an unsigned int. */
|
||||
@@ -745,30 +767,15 @@ static unsigned int nlz8(unsigned char x) {
|
||||
if ((UC) < 0x80) { \
|
||||
EMITTER(((unsigned char) (UC))); \
|
||||
} else if ((UC) < 0x0800) { \
|
||||
ADD_FIRST_SEQ(UC, 2, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 0, EMITTER); \
|
||||
ADD_SEQ(UC, 11, EMITTER); \
|
||||
} else if ((UC) < 0x10000) { \
|
||||
ADD_FIRST_SEQ(UC, 3, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 6, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 0, EMITTER); \
|
||||
ADD_SEQ(UC, 16, EMITTER); \
|
||||
} else if ((UC) < 0x200000) { \
|
||||
ADD_FIRST_SEQ(UC, 4, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 12, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 6, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 0, EMITTER); \
|
||||
ADD_SEQ(UC, 21, EMITTER); \
|
||||
} else if ((UC) < 0x4000000) { \
|
||||
ADD_FIRST_SEQ(UC, 5, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 18, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 12, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 6, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 0, EMITTER); \
|
||||
ADD_SEQ(UC, 26, EMITTER); \
|
||||
} else { \
|
||||
ADD_FIRST_SEQ(UC, 6, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 24, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 18, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 12, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 6, EMITTER); \
|
||||
ADD_NEXT_SEQ(UC, 0, EMITTER); \
|
||||
ADD_SEQ(UC, 31, EMITTER); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ char *fslash(char *catbuff, size_t size, const char *a) {
|
||||
}
|
||||
|
||||
// extension : html,gif..
|
||||
HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil) {
|
||||
HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil) {
|
||||
size_t i, last;
|
||||
|
||||
RUNTIME_TIME_CHECK_SIZE(size);
|
||||
|
||||
797
src/htscore.c
797
src/htscore.c
File diff suppressed because it is too large
Load Diff
@@ -135,41 +135,21 @@ typedef struct filecreate_params filecreate_params;
|
||||
typedef struct lien_url lien_url;
|
||||
#endif
|
||||
struct lien_url {
|
||||
char firstblock; // flag 1=premier malloc
|
||||
char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down
|
||||
int depth; // profondeur autorisée lien ; >0 forte 0=faible
|
||||
int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background
|
||||
int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine
|
||||
int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis
|
||||
//int moved; // pointeur sur moved
|
||||
int retry; // nombre de retry restants
|
||||
int testmode; // mode test uniquement, envoyer juste un head!
|
||||
char *adr; // adresse
|
||||
char *fil; // nom du fichier distant
|
||||
char *sav; // nom à sauver sur disque (avec chemin éventuel)
|
||||
char *cod; // chemin codebase éventuel si classe java
|
||||
char *former_adr; // adresse initiale (avant éventuel moved), peut être nulle
|
||||
char *former_fil; // nom du fichier distant initial (avant éventuel moved), peut être nul
|
||||
|
||||
int premier; // pointeur sur le premier lien qui a donné lieu aux autres liens du domaine
|
||||
int precedent; // pointeur sur le lien qui a donné lieu à ce lien précis
|
||||
int depth; // profondeur autorisée lien ; >0 forte 0=faible
|
||||
int pass2; // traiter après les autres, seconde passe. si == -1, lien traité en background
|
||||
char link_import; // lien importé à la suite d'un moved - ne pas appliquer les règles classiques up/down
|
||||
//int moved; // pointeur sur moved
|
||||
int retry; // nombre de retry restants
|
||||
int testmode; // mode test uniquement, envoyer juste un head!
|
||||
};
|
||||
|
||||
// adr, fil
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
typedef struct lien_adrfil lien_adrfil;
|
||||
#endif
|
||||
struct lien_adrfil {
|
||||
char adr[HTS_URLMAXSIZE * 2]; // adresse
|
||||
char fil[HTS_URLMAXSIZE * 2]; // nom du fichier distant
|
||||
};
|
||||
|
||||
// adr, fil, save
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
typedef struct lien_adrfilsave lien_adrfilsave;
|
||||
#endif
|
||||
struct lien_adrfilsave {
|
||||
lien_adrfil af;
|
||||
char save[HTS_URLMAXSIZE * 2]; // nom à sauver sur disque (avec chemin éventuel)
|
||||
};
|
||||
|
||||
// chargement de fichiers en 'arrière plan'
|
||||
@@ -275,7 +255,7 @@ typedef struct hash_struct hash_struct;
|
||||
#endif
|
||||
struct hash_struct {
|
||||
/* Links big array reference */
|
||||
const lien_url ***liens;
|
||||
const lien_url **liens;
|
||||
/* Savename (case insensitive ; lowercased) */
|
||||
inthash sav;
|
||||
/* Address and path */
|
||||
@@ -298,20 +278,6 @@ struct filecreate_params {
|
||||
char path[HTS_URLMAXSIZE * 2];
|
||||
};
|
||||
|
||||
/* Access macros. */
|
||||
#define heap(N) (opt->liens[N])
|
||||
#define heap_top_index() (opt->lien_tot - 1)
|
||||
#define heap_top() (heap(heap_top_index()))
|
||||
#define urladr() (heap(ptr)->adr)
|
||||
#define urlfil() (heap(ptr)->fil)
|
||||
#define savename() (heap(ptr)->sav)
|
||||
#define parenturladr() (heap(heap(ptr)->precedent)->adr)
|
||||
#define parenturlfil() (heap(heap(ptr)->precedent)->fil)
|
||||
#define parentsavename() (heap(heap(ptr)->precedent)->sav)
|
||||
#define relativeurladr() ((!parent_relative)?urladr():parenturladr())
|
||||
#define relativeurlfil() ((!parent_relative)?urlfil():parenturlfil())
|
||||
#define relativesavename() ((!parent_relative)?savename():parentsavename())
|
||||
|
||||
/* Library internal definictions */
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
|
||||
@@ -336,21 +302,7 @@ char *hts_cancel_file_pop(httrackp * opt);
|
||||
|
||||
#endif
|
||||
|
||||
// add a link on the heap
|
||||
int hts_record_link(httrackp * opt,
|
||||
const char *address, const char *file, const char *save,
|
||||
const char *ref_address, const char *ref_file,
|
||||
const char *codebase);
|
||||
|
||||
// index of the latest added link
|
||||
size_t hts_record_link_latest(httrackp *opt);
|
||||
|
||||
// invalidate an entry
|
||||
void hts_invalidate_link(httrackp * opt, int lpos);
|
||||
|
||||
// wipe all records
|
||||
void hts_record_init(httrackp *opt);
|
||||
void hts_record_free(httrackp *opt);
|
||||
//
|
||||
|
||||
//int httpmirror(char* url,int level,httrackp opt);
|
||||
int httpmirror(char *url1, httrackp * opt);
|
||||
@@ -360,7 +312,8 @@ int filesave(httrackp * opt, const char *adr, int len, const char *s,
|
||||
char *hts_cancel_file_pop(httrackp * opt);
|
||||
int check_fatal_io_errno(void);
|
||||
int engine_stats(void);
|
||||
void host_ban(httrackp * opt, int ptr, struct_back * sback, const char *host);
|
||||
void host_ban(httrackp * opt, lien_url ** liens, int ptr, int lien_tot,
|
||||
struct_back * sback, char *host);
|
||||
FILE *filecreate(filenote_strc * strct, const char *s);
|
||||
FILE *fileappend(filenote_strc * strct, const char *s);
|
||||
int filecreateempty(filenote_strc * strct, const char *filename);
|
||||
@@ -376,10 +329,10 @@ int fspc(httrackp * opt, FILE * fp, const char *type);
|
||||
char *next_token(char *p, int flag);
|
||||
|
||||
//
|
||||
char *readfile(const char *fil);
|
||||
char *readfile2(const char *fil, LLint * size);
|
||||
char *readfile_utf8(const char *fil);
|
||||
char *readfile_or(const char *fil, const char *defaultdata);
|
||||
char *readfile(char *fil);
|
||||
char *readfile2(char *fil, LLint * size);
|
||||
char *readfile_utf8(char *fil);
|
||||
char *readfile_or(char *fil, char *defaultdata);
|
||||
|
||||
#if 0
|
||||
void check_rate(TStamp stat_timestart, int maxrate);
|
||||
@@ -393,11 +346,11 @@ int liens_record(char *adr, char *fil, char *save, char *former_adr,
|
||||
int back_pluggable_sockets(struct_back * sback, httrackp * opt);
|
||||
int back_pluggable_sockets_strict(struct_back * sback, httrackp * opt);
|
||||
int back_fill(struct_back * sback, httrackp * opt, cache_back * cache,
|
||||
int ptr, int numero_passe);
|
||||
int backlinks_done(const struct_back * sback, lien_url ** liens,
|
||||
int lien_tot, int ptr);
|
||||
lien_url ** liens, int ptr, int numero_passe, int lien_tot);
|
||||
int backlinks_done(struct_back * sback, lien_url ** liens, int lien_tot,
|
||||
int ptr);
|
||||
int back_fillmax(struct_back * sback, httrackp * opt, cache_back * cache,
|
||||
int ptr, int numero_passe);
|
||||
lien_url ** liens, int ptr, int numero_passe, int lien_tot);
|
||||
|
||||
int ask_continue(httrackp * opt);
|
||||
int nombre_digit(int n);
|
||||
@@ -421,6 +374,7 @@ int htsAddLink(htsmoduleStruct * str, char *link);
|
||||
|
||||
// Void
|
||||
void voidf(void);
|
||||
|
||||
#define HTS_TOPINDEX "TOP_INDEX_HTTRACK"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,7 +45,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htszlib.h"
|
||||
#include "htscharset.h"
|
||||
#include "htsencoding.h"
|
||||
#include "htsmd5.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#if USE_BEGINTHREAD
|
||||
@@ -2007,7 +2006,8 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
cache.hashtable = (void *) cache_hashtable; /* copy backcache hash */
|
||||
cache.ro = 1; /* read only */
|
||||
if (cache.hashtable) {
|
||||
lien_adrfilsave afs;
|
||||
char BIGSTK adr[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK fil[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK url[HTS_URLMAXSIZE * 2];
|
||||
char linepos[256];
|
||||
int pos;
|
||||
@@ -2030,50 +2030,52 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
/* */
|
||||
a++;
|
||||
/* read "host/file" */
|
||||
a += binput(a, afs.af.adr, HTS_URLMAXSIZE);
|
||||
a += binput(a, afs.af.fil, HTS_URLMAXSIZE);
|
||||
a += binput(a, adr, HTS_URLMAXSIZE);
|
||||
a += binput(a, fil, HTS_URLMAXSIZE);
|
||||
url[0] = '\0';
|
||||
if (!link_has_authority(afs.af.adr))
|
||||
if (!link_has_authority(adr))
|
||||
strcatbuff(url, "http://");
|
||||
strcatbuff(url, afs.af.adr);
|
||||
strcatbuff(url, afs.af.fil);
|
||||
strcatbuff(url, adr);
|
||||
strcatbuff(url, fil);
|
||||
/* read position */
|
||||
a += binput(a, linepos, 200);
|
||||
sscanf(linepos, "%d", &pos);
|
||||
if (!hasFilter
|
||||
|| (strjoker(url, filter, NULL, NULL) != NULL)
|
||||
) {
|
||||
r = cache_read_ro(opt, &cache, afs.af.adr, afs.af.fil, "", NULL); // lire entrée cache + data
|
||||
r = cache_read_ro(opt, &cache, adr, fil, "", NULL); // lire entrée cache + data
|
||||
if (r.statuscode != -1) { // No errors
|
||||
found++;
|
||||
if (!hasFilter) {
|
||||
fprintf(stdout, "%s%s%s\r\n",
|
||||
(link_has_authority(afs.af.adr)) ? "" :
|
||||
"http://", afs.af.adr, afs.af.fil);
|
||||
(link_has_authority(adr)) ? "" :
|
||||
"http://", adr, fil);
|
||||
} else {
|
||||
char msg[256], cdate[256];
|
||||
char BIGSTK sav[HTS_URLMAXSIZE * 2];
|
||||
|
||||
infostatuscode(msg, r.statuscode);
|
||||
time_gmt_rfc822(cdate);
|
||||
|
||||
fprintf(stdout, "HTTP/1.1 %d %s\r\n",
|
||||
r.statuscode, r.msg[0] ? r.msg : msg);
|
||||
fprintf(stdout, "X-Host: %s\r\n", afs.af.adr);
|
||||
fprintf(stdout, "X-File: %s\r\n", afs.af.fil);
|
||||
fprintf(stdout, "X-Host: %s\r\n", adr);
|
||||
fprintf(stdout, "X-File: %s\r\n", fil);
|
||||
fprintf(stdout, "X-URL: %s%s%s\r\n",
|
||||
(link_has_authority(afs.af.adr)) ? "" :
|
||||
"http://", afs.af.adr, afs.af.fil);
|
||||
(link_has_authority(adr)) ? "" :
|
||||
"http://", adr, fil);
|
||||
if (url_savename
|
||||
(&afs, /*former */ NULL,
|
||||
/*referer_adr */
|
||||
(adr, fil, sav, /*former_adr */ NULL,
|
||||
/*former_fil */ NULL, /*referer_adr */
|
||||
NULL, /*referer_fil */ NULL,
|
||||
/*opt */ opt, /*sback */ NULL,
|
||||
/*opt */ opt, /*liens */ NULL,
|
||||
/*lien_tot */ 0, /*sback */ NULL,
|
||||
/*cache */ &cache, /*hash */ NULL, /*ptr */
|
||||
0, /*numero_passe */ 0, /*mime_type */
|
||||
NULL) != -1) {
|
||||
if (fexist(afs.save)) {
|
||||
if (fexist(sav)) {
|
||||
fprintf(stdout, "Content-location: %s\r\n",
|
||||
afs.save);
|
||||
sav);
|
||||
}
|
||||
}
|
||||
fprintf(stdout, "Date: %s\r\n", cdate);
|
||||
@@ -2408,7 +2410,6 @@ HTSEXT_API int hts_main2(int argc, char **argv, httrackp * opt) {
|
||||
return 0;
|
||||
break;
|
||||
case '7': // hashtable selftest: httrack -#7 nb_entries
|
||||
md5selftest();
|
||||
if (++na < argc) {
|
||||
char *const snum = strdup(argv[na]);
|
||||
unsigned long count = 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,7 @@ EOF
|
||||
i=$[${i}+1]
|
||||
done
|
||||
echo -e " /* $A */"
|
||||
echo -e " case ${hash}u:"
|
||||
echo -e " case ${hash}:"
|
||||
echo -e " if (len == ${#ent} /* && strncmp(ent, \"${ent}\") == 0 */) {"
|
||||
echo -e " return ${code};"
|
||||
echo -e " }"
|
||||
|
||||
@@ -54,7 +54,7 @@ Please visit our Website: http://www.httrack.com
|
||||
// optionnel: taille à contrôller (ou numéro, etc) en pointeur
|
||||
// (en de détection de *size, la taille limite est écrite par dessus *size)
|
||||
// exemple: +-*.gif*[<5] == supprimer GIF si <5KB
|
||||
int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size,
|
||||
int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size,
|
||||
int *size_flag, int *depth) {
|
||||
int verdict = 0; // on sait pas
|
||||
int i;
|
||||
@@ -101,7 +101,7 @@ int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * siz
|
||||
// cet algo est 'un peu' récursif mais ne consomme pas trop de tm
|
||||
// * = toute lettre
|
||||
// --?-- : spécifique à HTTrack et aux ?
|
||||
HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size,
|
||||
HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size,
|
||||
int *size_flag) {
|
||||
//int err=0;
|
||||
if (strnotempty(joker) == 0) { // fin de chaine joker
|
||||
@@ -262,7 +262,7 @@ HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * s
|
||||
|
||||
{
|
||||
int i, max;
|
||||
const char *adr;
|
||||
char *adr;
|
||||
|
||||
// la chaine doit se terminer exactement
|
||||
if (cut) {
|
||||
@@ -335,8 +335,8 @@ HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * s
|
||||
// exemple: find dans un texte de strcpybuff(*[A-Z,a-z],"*[0-9]"); va rechercher la première occurence
|
||||
// d'un strcpy sur une variable ayant un nom en lettres et copiant une chaine de chiffres
|
||||
// ATTENTION!! Eviter les jokers en début, où gare au temps machine!
|
||||
const char *strjokerfind(const char *chaine, const char *joker) {
|
||||
const char *adr;
|
||||
char *strjokerfind(char *chaine, char *joker) {
|
||||
char *adr;
|
||||
|
||||
while(*chaine) {
|
||||
if ((adr = strjoker(chaine, joker, NULL, NULL))) { // ok trouvé
|
||||
|
||||
@@ -39,11 +39,11 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#include "htsbase.h"
|
||||
|
||||
int fa_strjoker(int type, char **filters, int nfil, const char *nom, LLint * size,
|
||||
int fa_strjoker(int type, char **filters, int nfil, char *nom, LLint * size,
|
||||
int *size_flag, int *depth);
|
||||
HTS_INLINE const char *strjoker(const char *chaine, const char *joker, LLint * size,
|
||||
HTS_INLINE char *strjoker(char *chaine, char *joker, LLint * size,
|
||||
int *size_flag);
|
||||
const char *strjokerfind(const char *chaine, const char *joker);
|
||||
char *strjokerfind(char *chaine, char *joker);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -142,7 +142,7 @@ int run_launch_ftp(FTPDownloadStruct * pStruct) {
|
||||
#endif
|
||||
char BIGSTK adr_ip[1024];
|
||||
char *adr, *real_adr;
|
||||
const char *ftp_filename = "";
|
||||
char *ftp_filename = "";
|
||||
int timeout = 300; // timeout
|
||||
int timeout_onfly = 8; // attente réponse supplémentaire
|
||||
int transfer_list = 0; // directory
|
||||
@@ -913,7 +913,7 @@ FILE *dd = NULL;
|
||||
|
||||
// routines de réception/émission
|
||||
// 0 = ERROR
|
||||
int send_line(T_SOC soc, const char *data) {
|
||||
int send_line(T_SOC soc, char *data) {
|
||||
char BIGSTK line[1024];
|
||||
|
||||
if (_DEBUG_HEAD) {
|
||||
|
||||
@@ -68,7 +68,7 @@ int back_launch_ftp(FTPDownloadStruct * params);
|
||||
#endif
|
||||
|
||||
int run_launch_ftp(FTPDownloadStruct * params);
|
||||
int send_line(T_SOC soc, const char *data);
|
||||
int send_line(T_SOC soc, char *data);
|
||||
int get_ftp_line(T_SOC soc, char *line, size_t line_size, int timeout);
|
||||
T_SOC get_datasocket(char *to_send, size_t to_send_size);
|
||||
int stop_ftp(lien_back * back);
|
||||
|
||||
@@ -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-10"
|
||||
#define HTTRACK_VERSIONID "3.48.10"
|
||||
#define HTTRACK_VERSION "3.48-9"
|
||||
#define HTTRACK_VERSIONID "3.48.9"
|
||||
#define HTTRACK_AFF_VERSION "3.x"
|
||||
#define HTTRACK_LIB_VERSION "2.0"
|
||||
|
||||
@@ -132,6 +132,11 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#endif
|
||||
|
||||
// don't spare memory usage by default
|
||||
#ifndef HTS_SPARE_MEMORY
|
||||
#define HTS_SPARE_MEMORY 0
|
||||
#endif
|
||||
|
||||
#ifndef BIGSTK
|
||||
#define BIGSTK
|
||||
#endif
|
||||
@@ -201,10 +206,17 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
#endif
|
||||
|
||||
#if HTS_SPARE_MEMORY==0
|
||||
/* Taille max d'une URL */
|
||||
#define HTS_URLMAXSIZE 1024
|
||||
/* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */
|
||||
#define HTS_CDLMAXSIZE 1024
|
||||
#else
|
||||
/* Taille max d'une URL */
|
||||
#define HTS_URLMAXSIZE 256
|
||||
/* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */
|
||||
#define HTS_CDLMAXSIZE 1024
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 1998-2014 Xavier Roche and other contributors */
|
||||
#define HTTRACK_AFF_AUTHORS "[XR&CO'2014]"
|
||||
@@ -245,14 +257,8 @@ Please visit our Website: http://www.httrack.com
|
||||
#define HTSEXT_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
/* See <http://gcc.gnu.org/wiki/Visibility> */
|
||||
#if ( ( defined(__GNUC__) && ( __GNUC__ >= 4 ) ) \
|
||||
|| ( defined(HAVE_VISIBILITY) && HAVE_VISIBILITY ) )
|
||||
#define HTSEXT_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define HTSEXT_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef HTS_LONGLONG
|
||||
#ifdef HTS_NO_64_BIT
|
||||
@@ -323,6 +329,11 @@ typedef unsigned __int32 T_SOC;
|
||||
typedef int T_SOC;
|
||||
#endif
|
||||
|
||||
/* Default alignement */
|
||||
#ifndef HTS_ALIGN
|
||||
#define HTS_ALIGN (sizeof(void*))
|
||||
#endif
|
||||
|
||||
/* IPV4, IPV6 and various unified structures */
|
||||
#define HTS_MAXADDRLEN 64
|
||||
|
||||
@@ -367,7 +378,11 @@ typedef int T_SOC;
|
||||
#define LOCAL_SOCKET_ID -2
|
||||
|
||||
// taille de chaque buffer (10 sockets 650 ko)
|
||||
#if HTS_SPARE_MEMORY==0
|
||||
#define TAILLE_BUFFER 65536
|
||||
#else
|
||||
#define TAILLE_BUFFER 8192
|
||||
#endif
|
||||
|
||||
#ifdef HTS_DO_NOT_USE_PTHREAD
|
||||
#error needs threads support
|
||||
|
||||
@@ -307,15 +307,26 @@ 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) {
|
||||
void hash_write(hash_struct * hash, int lpos) {
|
||||
/* first entry: destination filename (lowercased) */
|
||||
inthash_write(hash->sav, (*hash->liens)[lpos]->sav, lpos);
|
||||
inthash_write(hash->sav, hash->liens[lpos]->sav, lpos);
|
||||
|
||||
/* second entry: URL address and path */
|
||||
inthash_write(hash->adrfil, (char*) (*hash->liens)[lpos], lpos);
|
||||
inthash_write(hash->adrfil, (char*) 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);
|
||||
if (hash->liens[lpos]->former_adr) { // former_adr existe?
|
||||
inthash_write(hash->former_adrfil, (char*) hash->liens[lpos], lpos);
|
||||
}
|
||||
}
|
||||
|
||||
void hash_invalidate_entry(hash_struct * hash, int lpos) {
|
||||
if (inthash_remove(hash->adrfil, (char*) hash->liens[lpos])) {
|
||||
/* devalidate entry now it is removed from hashtable */
|
||||
strcpybuff(hash->liens[lpos]->adr, "!");
|
||||
/* add back */
|
||||
inthash_write(hash->adrfil, (char*) hash->liens[lpos], lpos);
|
||||
} else {
|
||||
assertf(! "error invalidating hash entry");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ void hash_init(httrackp *opt, hash_struct *hash, int normalized);
|
||||
void hash_free(hash_struct *hash);
|
||||
int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
|
||||
hash_struct_type type);
|
||||
void hash_write(hash_struct * hash, size_t lpos);
|
||||
void hash_write(hash_struct * hash, int lpos);
|
||||
void hash_invalidate_entry(hash_struct * hash, int lpos);
|
||||
int *hash_calc_chaine(hash_struct * hash, hash_struct_type type, int pos);
|
||||
unsigned long int hash_cle(const char *nom1, const char *nom2);
|
||||
#endif
|
||||
|
||||
@@ -52,7 +52,7 @@ Please visit our Website: http://www.httrack.com
|
||||
/* END specific definitions */
|
||||
|
||||
#define waitkey if (more) { char s[4]; printf("\nMORE.. q to quit\n"); linput(stdin,s,4); if (strcmp(s,"q")==0) quit=1; else printf("Page %d\n\n",++m); }
|
||||
void infomsg(const char *msg) {
|
||||
void infomsg(char *msg) {
|
||||
int l = 0;
|
||||
int m = 0;
|
||||
int more = 0;
|
||||
@@ -332,7 +332,7 @@ void help_wizard(httrackp * opt) {
|
||||
printf("\n");
|
||||
|
||||
// couper en morceaux
|
||||
argv[0] = strdup("winhttrack");
|
||||
argv[0] = "winhttrack";
|
||||
argv[1] = cmd;
|
||||
argc++;
|
||||
while(cmd[i]) {
|
||||
@@ -364,15 +364,15 @@ void help_wizard(httrackp * opt) {
|
||||
#undef str
|
||||
#undef argv
|
||||
}
|
||||
int help_query(const char *list, int def) {
|
||||
int help_query(char *list, int def) {
|
||||
char s[256];
|
||||
const char *a;
|
||||
char *a;
|
||||
int opt;
|
||||
int n = 1;
|
||||
|
||||
a = list;
|
||||
while(strnotempty(a)) {
|
||||
const char *b = strchr(a, '|');
|
||||
char *b = strchr(a, '|');
|
||||
|
||||
if (b) {
|
||||
char str[256];
|
||||
@@ -455,7 +455,7 @@ void help_catchurl(const char *dest_path) {
|
||||
}
|
||||
|
||||
// Créer un index.html vide
|
||||
void make_empty_index(const char *str) {
|
||||
void make_empty_index(char *str) {
|
||||
#if 0
|
||||
if (!fexist(fconcat(str, "index.html"))) {
|
||||
FILE *fp = fopen(fconcat(str, "index.html"), "wb");
|
||||
@@ -473,7 +473,7 @@ void make_empty_index(const char *str) {
|
||||
|
||||
// mini-aide (h: help)
|
||||
// y
|
||||
void help(const char *app, int more) {
|
||||
void help(char *app, int more) {
|
||||
char info[2048];
|
||||
|
||||
infomsg("");
|
||||
@@ -605,7 +605,7 @@ void help(const char *app, int more) {
|
||||
infomsg
|
||||
(" %F footer string in Html code (-%F \"Mirrored [from host %s [file %s [at %s]]]\"");
|
||||
infomsg(" %l preffered language (-%l \"fr, en, jp, *\"");
|
||||
infomsg(" %a accepted formats (-%a \"text/html,image/png;q=0.9,*/*;q=0.1\"");
|
||||
infomsg(" %a accepted formats (-%l \"text/html,image/png,image/jpeg,image/gif;q=0.9,*/*;q=0.1\"");
|
||||
infomsg(" %X additional HTTP header line (-%X \"X-Magic: 42\"");
|
||||
infomsg("");
|
||||
infomsg("Log, index, cache");
|
||||
|
||||
@@ -43,11 +43,11 @@ Please visit our Website: http://www.httrack.com
|
||||
typedef struct httrackp httrackp;
|
||||
#endif
|
||||
|
||||
void infomsg(const char *msg);
|
||||
void help(const char *app, int more);
|
||||
void make_empty_index(const char *str);
|
||||
void infomsg(char *msg);
|
||||
void help(char *app, int more);
|
||||
void make_empty_index(char *str);
|
||||
void help_wizard(httrackp * opt);
|
||||
int help_query(const char *list, int def);
|
||||
int help_query(char *list, int def);
|
||||
void help_catchurl(const char *dest_path);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -103,7 +103,7 @@ Please visit our Website: http://www.httrack.com
|
||||
|
||||
/* End of Keyword Indexer Parameters */
|
||||
|
||||
int strcpos(const char *adr, char c);
|
||||
int strcpos(char *adr, char c);
|
||||
int mystrcmp(const void *_e1, const void *_e2);
|
||||
|
||||
// Global variables
|
||||
@@ -468,8 +468,8 @@ void index_finish(const char *indexpath, int mode) {
|
||||
/* Subroutines */
|
||||
|
||||
#if HTS_MAKE_KEYWORD_INDEX
|
||||
int strcpos(const char *adr, char c) {
|
||||
const char *apos = strchr(adr, c);
|
||||
int strcpos(char *adr, char c) {
|
||||
char *apos = strchr(adr, c);
|
||||
|
||||
if (apos)
|
||||
return (int) (apos - adr);
|
||||
|
||||
@@ -493,9 +493,8 @@ static char *printname(char rname[1024], char name[1024]) {
|
||||
|
||||
p = &name[0];
|
||||
|
||||
if (*p != '[') {
|
||||
return rname; // ""
|
||||
}
|
||||
if (*p != '[')
|
||||
return "";
|
||||
p += 2;
|
||||
//rname=(char*)calloct(strlen(name)+8,sizeof(char));
|
||||
p1 = rname;
|
||||
@@ -505,13 +504,13 @@ static char *printname(char rname[1024], char name[1024]) {
|
||||
if (*p == ';') {
|
||||
*p1 = '\0';
|
||||
strcat(rname, ".class");
|
||||
return rname;
|
||||
return (rname);
|
||||
} else
|
||||
*p1 = *p;
|
||||
p1++;
|
||||
}
|
||||
p1 -= 3;
|
||||
*p1 = '\0';
|
||||
return rname;
|
||||
return (rname);
|
||||
|
||||
}
|
||||
|
||||
149
src/htslib.c
149
src/htslib.c
@@ -609,7 +609,7 @@ void hts_init_htsblk(htsblk * r) {
|
||||
|
||||
// ouvre une liaison http, envoie une requète GET et réceptionne le header
|
||||
// retour: socket
|
||||
T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour) {
|
||||
T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour) {
|
||||
// / GET, traiter en-tête
|
||||
return http_xfopen(opt, 0, 1, 1, NULL, adr, fil, retour);
|
||||
}
|
||||
@@ -620,11 +620,10 @@ T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * reto
|
||||
// waitconnect: attendre le connect()
|
||||
// note: dans retour, on met les params du proxy
|
||||
T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect,
|
||||
const char *xsend, const char *adr, const char *fil, htsblk * retour) {
|
||||
char *xsend, char *adr, char *fil, htsblk * retour) {
|
||||
//htsblk retour;
|
||||
//int bufl=TAILLE_BUFFER; // 8Ko de buffer
|
||||
T_SOC soc = INVALID_SOCKET;
|
||||
char BIGSTK tempo_fil[HTS_URLMAXSIZE * 2];
|
||||
|
||||
//char *p,*q;
|
||||
|
||||
@@ -700,8 +699,10 @@ T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect,
|
||||
(fconv
|
||||
(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt),
|
||||
unescape_http(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt), fil + 1)))) {
|
||||
strcpybuff(tempo_fil, fil + 1);
|
||||
fil = tempo_fil;
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(tempo, fil + 1);
|
||||
strcpybuff(fil, tempo);
|
||||
}
|
||||
// Ouvrir
|
||||
retour->totalsize = fsize(fconv(OPT_GET_BUFF(opt), OPT_GET_BUFF_SIZE(opt),
|
||||
@@ -844,16 +845,15 @@ static void print_buffer(buff_struct*const str, const char *format, ...) {
|
||||
}
|
||||
|
||||
// envoi d'une requète
|
||||
int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
const char *xsend, const char *adr, const char *fil,
|
||||
const char *referer_adr, const char *referer_fil,
|
||||
int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend,
|
||||
char *adr, char *fil, char *referer_adr, char *referer_fil,
|
||||
htsblk * retour) {
|
||||
char BIGSTK buffer_head_request[8192];
|
||||
buff_struct bstr = { buffer_head_request, sizeof(buffer_head_request), 0 };
|
||||
|
||||
//int use_11=0; // HTTP 1.1 utilisé
|
||||
int direct_url = 0; // ne pas analyser l'url (exemple: ftp://)
|
||||
const char *search_tag = NULL;
|
||||
char *search_tag = NULL;
|
||||
|
||||
// Initialize buffer
|
||||
buffer_head_request[0] = '\0';
|
||||
@@ -1054,7 +1054,7 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
}
|
||||
|
||||
{
|
||||
const char *real_adr = jump_identification(adr);
|
||||
char *real_adr = jump_identification(adr);
|
||||
|
||||
// Mandatory per RFC2616
|
||||
if (!direct_url) { // pas ftp:// par exemple
|
||||
@@ -1099,12 +1099,12 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
/* Authentification */
|
||||
{
|
||||
char autorisation[1100];
|
||||
const char *a;
|
||||
char *a;
|
||||
|
||||
autorisation[0] = '\0';
|
||||
if (link_has_authorization(adr)) { // ohh une authentification!
|
||||
const char *a = jump_identification(adr);
|
||||
const char *astart = jump_protocol(adr);
|
||||
char *a = jump_identification(adr);
|
||||
char *astart = jump_protocol(adr);
|
||||
|
||||
if (!direct_url) { // pas ftp:// par exemple
|
||||
char user_pass[256];
|
||||
@@ -1184,8 +1184,8 @@ int http_sendhead(httrackp * opt, t_cookie * cookie, int mode,
|
||||
}
|
||||
|
||||
// traiter 1ere ligne d'en tête
|
||||
void treatfirstline(htsblk * retour, const char *rcvd) {
|
||||
const char *a = rcvd;
|
||||
void treatfirstline(htsblk * retour, char *rcvd) {
|
||||
char *a = rcvd;
|
||||
|
||||
// exemple:
|
||||
// HTTP/1.0 200 OK
|
||||
@@ -1255,7 +1255,7 @@ void treatfirstline(htsblk * retour, const char *rcvd) {
|
||||
|
||||
// traiter ligne par ligne l'en tête
|
||||
// gestion des cookies
|
||||
void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour,
|
||||
void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour,
|
||||
char *rcvd) {
|
||||
int p;
|
||||
|
||||
@@ -1388,7 +1388,7 @@ void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * ret
|
||||
}
|
||||
} else if ((p = strfield(rcvd, "Content-Range:")) != 0) {
|
||||
// Content-Range: bytes 0-70870/70871
|
||||
const char *a;
|
||||
char *a;
|
||||
|
||||
for(a = rcvd + p; is_space(*a); a++) ;
|
||||
if (strncasecmp(a, "bytes ", 6) == 0) {
|
||||
@@ -1984,12 +1984,42 @@ LLint http_xfread1(htsblk * r, int bufl) {
|
||||
}
|
||||
}
|
||||
|
||||
// teste une adresse, et suit l'éventuel chemin "moved"
|
||||
// retourne 200 ou le code d'erreur (404=NOT FOUND, etc)
|
||||
// copie dans loc la véritable adresse si celle-ci est différente
|
||||
htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc) {
|
||||
htsblk retour;
|
||||
int retry = 0;
|
||||
int tryagain;
|
||||
|
||||
// note: "RFC says"
|
||||
// 5 boucles au plus, on en teste au plus 8 ici
|
||||
// sinon abandon..
|
||||
do {
|
||||
tryagain = 0;
|
||||
switch ((retour = http_test(opt, adr, fil, loc)).statuscode) {
|
||||
case HTTP_OK:
|
||||
break; // ok!
|
||||
case HTTP_MOVED_PERMANENTLY:
|
||||
case HTTP_FOUND:
|
||||
case HTTP_SEE_OTHER:
|
||||
case HTTP_TEMPORARY_REDIRECT: // moved!
|
||||
// recalculer adr et fil!
|
||||
if (ident_url_absolute(loc, adr, fil) != -1) {
|
||||
tryagain = 1; // retenter
|
||||
retry++; // ..encore une fois
|
||||
}
|
||||
}
|
||||
} while((tryagain) && (retry < 5 + 3));
|
||||
return retour;
|
||||
}
|
||||
|
||||
// teste si une URL (validité, header, taille)
|
||||
// retourne 200 ou le code d'erreur (404=NOT FOUND, etc)
|
||||
// en cas de moved xx, dans location
|
||||
// abandonne désormais au bout de 30 secondes (aurevoir les sites
|
||||
// qui nous font poireauter 5 heures..) -> -2=timeout
|
||||
htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc) {
|
||||
htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc) {
|
||||
T_SOC soc;
|
||||
htsblk retour;
|
||||
|
||||
@@ -2310,12 +2340,12 @@ T_SOC newhttp(httrackp * opt, const char *_iadr, htsblk * retour, int port,
|
||||
// couper http://www.truc.fr/pub/index.html -> www.truc.fr /pub/index.html
|
||||
// retour=-1 si erreur.
|
||||
// si file://... alors adresse=file:// (et coupe le ?query dans ce cas)
|
||||
int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
|
||||
int ident_url_absolute(const char *url, char *adr, char *fil) {
|
||||
int pos = 0;
|
||||
int scheme = 0;
|
||||
|
||||
// effacer adrfil->adr et adrfil->fil
|
||||
adrfil->adr[0] = adrfil->fil[0] = '\0';
|
||||
// effacer adr et fil
|
||||
adr[0] = fil[0] = '\0';
|
||||
|
||||
#if HDEBUG
|
||||
printf("protocol: %s\n", url);
|
||||
@@ -2334,15 +2364,15 @@ int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
|
||||
// 1. optional scheme ":"
|
||||
if ((pos = strfield(url, "file:"))) { // fichier local!! (pour les tests)
|
||||
//!!p+=3;
|
||||
strcpybuff(adrfil->adr, "file://");
|
||||
strcpybuff(adr, "file://");
|
||||
} else if ((pos = strfield(url, "http:"))) { // HTTP
|
||||
//!!p+=3;
|
||||
} else if ((pos = strfield(url, "ftp:"))) { // FTP
|
||||
strcpybuff(adrfil->adr, "ftp://"); // FTP!!
|
||||
strcpybuff(adr, "ftp://"); // FTP!!
|
||||
//!!p+=3;
|
||||
#if HTS_USEOPENSSL
|
||||
} else if ((pos = strfield(url, "https:"))) { // HTTPS
|
||||
strcpybuff(adrfil->adr, "https://");
|
||||
strcpybuff(adr, "https://");
|
||||
#endif
|
||||
} else if (scheme) {
|
||||
return -1; // erreur non reconnu
|
||||
@@ -2355,13 +2385,13 @@ int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
|
||||
|
||||
// (url+pos) now points to the path (not net path)
|
||||
|
||||
//## if (adrfil->adr[0]!=lOCAL_CHAR) { // adrfil->adresse normale http
|
||||
if (!strfield(adrfil->adr, "file:")) { // PAS adrfil->file://
|
||||
//## if (adr[0]!=lOCAL_CHAR) { // adresse normale http
|
||||
if (!strfield(adr, "file:")) { // PAS file://
|
||||
const char *p, *q;
|
||||
|
||||
p = url + pos;
|
||||
|
||||
// p pointe sur le début de l'adrfil->adresse, ex: www.truc.fr/sommaire/index.html
|
||||
// p pointe sur le début de l'adresse, ex: www.truc.fr/sommaire/index.html
|
||||
q = strchr(jump_identification(p), '/');
|
||||
if (q == 0)
|
||||
q = strchr(jump_identification(p), '?'); // http://www.foo.com?bar=1
|
||||
@@ -2374,53 +2404,53 @@ int ident_url_absolute(const char *url, lien_adrfil *adrfil) {
|
||||
//strcpybuff(retour.msg,"Path too long");
|
||||
return -1; // erreur
|
||||
}
|
||||
// recopier adrfil->adresse www..
|
||||
strncatbuff(adrfil->adr, p, ((int) (q - p)));
|
||||
// *( adrfil->adr+( ((int) q) - ((int) p) ) )=0; // faut arrêter la fumette!
|
||||
// recopier adresse www..
|
||||
strncatbuff(adr, p, ((int) (q - p)));
|
||||
// *( adr+( ((int) q) - ((int) p) ) )=0; // faut arrêter la fumette!
|
||||
// recopier chemin /pub/..
|
||||
if (q[0] != '/') // page par défaut (/)
|
||||
strcatbuff(adrfil->fil, "/");
|
||||
strcatbuff(adrfil->fil, q);
|
||||
strcatbuff(fil, "/");
|
||||
strcatbuff(fil, q);
|
||||
// SECURITE:
|
||||
// simplifier url pour les ../
|
||||
fil_simplifie(adrfil->fil);
|
||||
} else { // localhost adrfil->file://
|
||||
fil_simplifie(fil);
|
||||
} else { // localhost file://
|
||||
const char *p;
|
||||
size_t i;
|
||||
char *a;
|
||||
|
||||
p = url + pos;
|
||||
if (*p == '/' || *p == '\\') { /* adrfil->file:///.. */
|
||||
strcatbuff(adrfil->fil, p); // fichier local ; adrfil->adr="#"
|
||||
if (*p == '/' || *p == '\\') { /* file:///.. */
|
||||
strcatbuff(fil, p); // fichier local ; adr="#"
|
||||
} else {
|
||||
if (p[1] != ':') {
|
||||
strcatbuff(adrfil->fil, "//"); /* adrfil->file://server/foo */
|
||||
strcatbuff(adrfil->fil, p);
|
||||
strcatbuff(fil, "//"); /* file://server/foo */
|
||||
strcatbuff(fil, p);
|
||||
} else {
|
||||
strcatbuff(adrfil->fil, p); // adrfil->file://C:\..
|
||||
strcatbuff(fil, p); // file://C:\..
|
||||
}
|
||||
}
|
||||
|
||||
a = strchr(adrfil->fil, '?');
|
||||
a = strchr(fil, '?');
|
||||
if (a)
|
||||
*a = '\0'; /* couper query (inutile pour adrfil->file:// lors de la requête) */
|
||||
// adrfil->filtrer les \\ -> / pour les fichiers DOS
|
||||
for(i = 0; adrfil->fil[i] != '\0'; i++)
|
||||
if (adrfil->fil[i] == '\\')
|
||||
adrfil->fil[i] = '/';
|
||||
*a = '\0'; /* couper query (inutile pour file:// lors de la requête) */
|
||||
// filtrer les \\ -> / pour les fichiers DOS
|
||||
for(i = 0; fil[i] != '\0'; i++)
|
||||
if (fil[i] == '\\')
|
||||
fil[i] = '/';
|
||||
}
|
||||
|
||||
// no hostname
|
||||
if (!strnotempty(adrfil->adr))
|
||||
if (!strnotempty(adr))
|
||||
return -1; // erreur non reconnu
|
||||
|
||||
// nommer au besoin.. (non utilisé normalement)
|
||||
if (!strnotempty(adrfil->fil))
|
||||
strcpybuff(adrfil->fil, "default-index.html");
|
||||
if (!strnotempty(fil))
|
||||
strcpybuff(fil, "default-index.html");
|
||||
|
||||
// case insensitive pour adrfil->adresse
|
||||
// case insensitive pour adresse
|
||||
{
|
||||
char *a = jump_identification(adrfil->adr);
|
||||
char *a = jump_identification(adr);
|
||||
|
||||
while(*a) {
|
||||
if ((*a >= 'A') && (*a <= 'Z'))
|
||||
@@ -2947,7 +2977,7 @@ int finput(T_SOC fd, char *s, int max) {
|
||||
|
||||
do {
|
||||
//c=fgetc(fp);
|
||||
if (read((int) fd, &c, 1) <= 0) {
|
||||
if (read(fd, &c, 1) <= 0) {
|
||||
c = 0;
|
||||
}
|
||||
if (c != 0) {
|
||||
@@ -3051,7 +3081,7 @@ int linputsoc_t(T_SOC soc, char *s, int max, int timeout) {
|
||||
}
|
||||
int linput_trim(FILE * fp, char *s, int max) {
|
||||
int rlen = 0;
|
||||
char *ls = (char *) malloct(max + 1);
|
||||
char *ls = (char *) malloct(max + 2);
|
||||
|
||||
s[0] = '\0';
|
||||
if (ls) {
|
||||
@@ -3123,8 +3153,8 @@ void rawlinput(FILE * fp, char *s, int max) {
|
||||
}
|
||||
|
||||
//cherche chaine, case insensitive
|
||||
char *strstrcase(char *s, const char *o) {
|
||||
while(*s && strfield(s, o) == 0)
|
||||
char *strstrcase(char *s, char *o) {
|
||||
while((*s) && (strfield(s, o) == 0))
|
||||
s++;
|
||||
if (*s == '\0')
|
||||
return NULL;
|
||||
@@ -4247,7 +4277,7 @@ int may_unknown2(httrackp * opt, const char *mime, const char *filename) {
|
||||
// -- Utils fichiers
|
||||
|
||||
// pretty print for i/o
|
||||
void fprintfio(FILE * fp, const char *buff, const char *prefix) {
|
||||
void fprintfio(FILE * fp, char *buff, char *prefix) {
|
||||
char nl = 1;
|
||||
|
||||
while(*buff) {
|
||||
@@ -4362,7 +4392,7 @@ typedef struct {
|
||||
char path[1024 + 4];
|
||||
int init;
|
||||
} hts_rootdir_strc;
|
||||
HTSEXT_API const char *hts_rootdir(char *file) {
|
||||
HTSEXT_API char *hts_rootdir(char *file) {
|
||||
static hts_rootdir_strc strc = { "", 0 };
|
||||
if (file) {
|
||||
if (!strc.init) {
|
||||
@@ -5461,8 +5491,13 @@ HTSEXT_API httrackp *hts_create_opt(void) {
|
||||
StringCopy(opt->path_log, "");
|
||||
StringCopy(opt->path_bin, "");
|
||||
//
|
||||
opt->maxlink = 100000; // 100,000 liens max par défaut
|
||||
#if HTS_SPARE_MEMORY==0
|
||||
opt->maxlink = 100000; // 100,000 liens max par défaut (400Kb)
|
||||
opt->maxfilter = 200; // 200 filtres max par défaut
|
||||
#else
|
||||
opt->maxlink = 10000; // 10,000 liens max par défaut (40Kb)
|
||||
opt->maxfilter = 50; // 50 filtres max par défaut
|
||||
#endif
|
||||
opt->maxcache = 1048576 * 32; // a peu près 32Mo en cache max -- OPTION NON PARAMETRABLE POUR L'INSTANT --
|
||||
//opt->maxcache_anticipate=256; // maximum de liens à anticiper
|
||||
opt->maxtime = -1; // temps max en secondes
|
||||
|
||||
41
src/htslib.h
41
src/htslib.h
@@ -50,14 +50,6 @@ typedef struct htsblk htsblk;
|
||||
#define HTS_DEF_FWSTRUCT_t_dnscache
|
||||
typedef struct t_dnscache t_dnscache;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
typedef struct lien_adrfil lien_adrfil;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
typedef struct lien_adrfilsave lien_adrfilsave;
|
||||
#endif
|
||||
|
||||
/* définitions globales */
|
||||
#include "htsglobal.h"
|
||||
@@ -257,12 +249,11 @@ LLint check_downloadable_bytes(int rate);
|
||||
HTSEXT_API int hts_uninit_module(void);
|
||||
|
||||
// fonctions principales
|
||||
T_SOC http_fopen(httrackp * opt, const char *adr, const char *fil, htsblk * retour);
|
||||
T_SOC http_fopen(httrackp * opt, char *adr, char *fil, htsblk * retour);
|
||||
T_SOC http_xfopen(httrackp * opt, int mode, int treat, int waitconnect,
|
||||
const char *xsend, const char *adr, const char *fil, htsblk * retour);
|
||||
int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, const char *xsend,
|
||||
const char *adr, const char *fil,
|
||||
const char *referer_adr, const char *referer_fil,
|
||||
char *xsend, char *adr, char *fil, htsblk * retour);
|
||||
int http_sendhead(httrackp * opt, t_cookie * cookie, int mode, char *xsend,
|
||||
char *adr, char *fil, char *referer_adr, char *referer_fil,
|
||||
htsblk * retour);
|
||||
|
||||
//int newhttp(char* iadr,char* err=NULL);
|
||||
@@ -272,12 +263,13 @@ HTS_INLINE void deletehttp(htsblk * r);
|
||||
HTS_INLINE int deleteaddr(htsblk * r);
|
||||
HTS_INLINE void deletesoc(T_SOC soc);
|
||||
HTS_INLINE void deletesoc_r(htsblk * r);
|
||||
htsblk http_test(httrackp * opt, const char *adr, const char *fil, char *loc);
|
||||
htsblk http_location(httrackp * opt, char *adr, char *fil, char *loc);
|
||||
htsblk http_test(httrackp * opt, char *adr, char *fil, char *loc);
|
||||
int check_readinput(htsblk * r);
|
||||
int check_readinput_t(T_SOC soc, int timeout);
|
||||
void treathead(t_cookie * cookie, const char *adr, const char *fil, htsblk * retour,
|
||||
void treathead(t_cookie * cookie, char *adr, char *fil, htsblk * retour,
|
||||
char *rcvd);
|
||||
void treatfirstline(htsblk * retour, const char *rcvd);
|
||||
void treatfirstline(htsblk * retour, char *rcvd);
|
||||
|
||||
// sous-fonctions
|
||||
LLint http_xfread1(htsblk * r, int bufl);
|
||||
@@ -323,8 +315,8 @@ 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);
|
||||
int ident_url_absolute(const char *url, lien_adrfil *adrfil);
|
||||
char *strstrcase(char *s, char *o);
|
||||
int ident_url_absolute(const char *url, char *adr, char *fil);
|
||||
void fil_simplifie(char *f);
|
||||
int is_unicode_utf8(const char *buffer, const size_t size);
|
||||
void map_characters(unsigned char *buffer, unsigned int size,
|
||||
@@ -332,10 +324,12 @@ void map_characters(unsigned char *buffer, unsigned int size,
|
||||
int ishtml(httrackp * opt, const char *urlfil);
|
||||
int ishtml_ext(const char *a);
|
||||
int ishttperror(int err);
|
||||
void guess_httptype(httrackp * opt, char *s, const char *fil);
|
||||
|
||||
int get_userhttptype(httrackp * opt, char *s, const char *fil);
|
||||
void give_mimext(char *s, const char *st);
|
||||
|
||||
int may_unknown(httrackp * opt, 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);
|
||||
|
||||
@@ -351,7 +345,7 @@ void hts_lowcase(char *s);
|
||||
void hts_replace(char *s, char from, char to);
|
||||
int multipleStringMatch(const char *s, const char *match);
|
||||
|
||||
void fprintfio(FILE * fp, const char *buff, const char *prefix);
|
||||
void fprintfio(FILE * fp, char *buff, char *prefix);
|
||||
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
@@ -619,15 +613,6 @@ HTS_STATIC int compare_mime(httrackp * opt, const char *mime, const char *file,
|
||||
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
} else {
|
||||
return (size_t) -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* dirent() compatibility */
|
||||
#ifdef _WIN32
|
||||
#define HTS_DIRENT_SIZE 256
|
||||
|
||||
26
src/htsmd5.c
26
src/htsmd5.c
@@ -1,4 +1,4 @@
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
HTTrack Website Copier, Offline Browser for Windows and Unix
|
||||
Copyright (C) 1998-2014 Xavier Roche and other contributors
|
||||
@@ -41,10 +41,8 @@ Please visit our Website: http://www.httrack.com
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "htsmd5.h"
|
||||
#include "md5.h"
|
||||
#include "htssafe.h"
|
||||
|
||||
int domd5mem(const char *buf, size_t len, char *digest, int asAscii) {
|
||||
int endian = 1;
|
||||
@@ -79,25 +77,3 @@ unsigned long int md5sum32(const char *buff) {
|
||||
domd5mem(buff, strlen(buff), u.md5digest, 0);
|
||||
return u.hash;
|
||||
}
|
||||
|
||||
void md5selftest() {
|
||||
static const char str1[] = "The quick brown fox jumps over the lazy dog\n";
|
||||
static const char str1m[] = "37c4b87edffc5d198ff5a185cee7ee09";
|
||||
static const char str2[] = "Hello";
|
||||
static const char str2m[] = "8b1a9953c4611296a827abf8c47804d7";
|
||||
char digest[64];
|
||||
#define MDCHECK(VAR, VARMD) do { \
|
||||
memset(digest, 0xCC, sizeof(digest)); \
|
||||
domd5mem(VAR, sizeof(VAR) - 1, digest, 1); \
|
||||
if (strcmp(digest, VARMD) != 0) { \
|
||||
fprintf(stderr, \
|
||||
"error: md5 selftest failed: '%s' => '%s' (!= '%s')\n", \
|
||||
VAR, digest, VARMD); \
|
||||
assert(! "md5 selftest failed"); \
|
||||
} \
|
||||
} while(0)
|
||||
MDCHECK(str1, str1m);
|
||||
MDCHECK(str2, str2m);
|
||||
#undef MDCHECK
|
||||
fprintf(stderr, "md5 selftest succeeded\n");
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
int domd5mem(const char *buf, size_t len, char *digest, int asAscii);
|
||||
unsigned long int md5sum32(const char *buff);
|
||||
void md5selftest(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -218,17 +218,17 @@ void htspe_init(void) {
|
||||
/* See CVE-2010-5252 */
|
||||
#if (defined(_WIN32) && (!defined(_DEBUG)))
|
||||
{
|
||||
/* >= Windows Server 2003 (Andy Hewitt) */
|
||||
const DWORD dwVersion = GetVersion();
|
||||
const DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
const DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||
const int hasSetDllDirectory =
|
||||
dwMajorVersion >= 6 || ( dwMajorVersion == 5 && dwMinorVersion >= 2 );
|
||||
/* See KB 2389418
|
||||
"If this parameter is an empty string (""), the call removes the
|
||||
current directory from the default DLL search order" */
|
||||
BOOL (WINAPI*const k32_SetDllDirectoryA)(LPCSTR) =
|
||||
(BOOL (WINAPI *)(LPCSTR))
|
||||
GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA");
|
||||
if (k32_SetDllDirectoryA != NULL && !k32_SetDllDirectoryA("")) {
|
||||
if (hasSetDllDirectory && !SetDllDirectory("")) {
|
||||
/* Do no choke on NT or 98SE with KernelEx NT API (James Blough) */
|
||||
const DWORD dwVersion = GetVersion();
|
||||
const DWORD dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
|
||||
const DWORD dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
|
||||
if (dwMajorVersion >= 5) {
|
||||
assertf(!"SetDllDirectory failed");
|
||||
}
|
||||
|
||||
@@ -104,12 +104,17 @@ struct htsmoduleStruct {
|
||||
httrackp *opt;
|
||||
|
||||
/* Internal use - please don't touch */
|
||||
lien_url **liens;
|
||||
struct_back *sback;
|
||||
cache_back *cache;
|
||||
hash_struct *hashptr;
|
||||
int numero_passe;
|
||||
int add_tab_alloc;
|
||||
/* */
|
||||
int *lien_tot_;
|
||||
int *ptr_;
|
||||
size_t *lien_size_;
|
||||
char **lien_buffer_;
|
||||
const char *page_charset_;
|
||||
/* Internal use - please don't touch */
|
||||
|
||||
|
||||
337
src/htsname.c
337
src/htsname.c
@@ -47,15 +47,15 @@ Please visit our Website: http://www.httrack.com
|
||||
{ /* ajout nom */\
|
||||
char BIGSTK buff[HTS_URLMAXSIZE*2];\
|
||||
buff[0]='\0';\
|
||||
strncatbuff(buff,start_pos,nom_pos - start_pos);\
|
||||
url_savename_addstr(afs->save, buff);\
|
||||
strncatbuff(buff,start_pos,(int) (nom_pos - start_pos));\
|
||||
url_savename_addstr(save,buff);\
|
||||
}
|
||||
|
||||
#define ADD_STANDARD_NAME(shortname) \
|
||||
{ /* ajout nom */\
|
||||
char BIGSTK buff[HTS_URLMAXSIZE*2];\
|
||||
standard_name(buff,dot_pos,nom_pos,fil_complete,(shortname));\
|
||||
url_savename_addstr(afs->save, buff);\
|
||||
url_savename_addstr(save,buff);\
|
||||
}
|
||||
|
||||
/* Avoid stupid DOS system folders/file such as 'nul' */
|
||||
@@ -82,11 +82,11 @@ static const char *hts_tbdev[] = {
|
||||
HTS_STAT.stat_errors=fspc(opt,NULL,"error"); \
|
||||
HTS_STAT.stat_warnings=fspc(opt,NULL,"warning"); \
|
||||
HTS_STAT.stat_infos=fspc(opt,NULL,"info"); \
|
||||
HTS_STAT.nbk=backlinks_done(sback,opt->liens,opt->lien_tot,ptr); \
|
||||
HTS_STAT.nbk=backlinks_done(sback,liens,lien_tot,ptr); \
|
||||
HTS_STAT.nb=back_transferred(HTS_STAT.stat_bytes,sback); \
|
||||
/* Check */ \
|
||||
{ \
|
||||
if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count,-1,ptr,opt->lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \
|
||||
if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count,-1,ptr,lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \
|
||||
return -1; \
|
||||
} \
|
||||
} \
|
||||
@@ -139,10 +139,10 @@ static void cleanEndingSpaceOrDot(char *s) {
|
||||
|
||||
// forme le nom du fichier à sauver (save) à partir de fil et adr
|
||||
// système intelligent, qui renomme en cas de besoin (exemple: deux INDEX.HTML et index.html)
|
||||
int url_savename(lien_adrfilsave *const afs,
|
||||
lien_adrfil *const former,
|
||||
const char *referer_adr, const char *referer_fil,
|
||||
httrackp * opt, struct_back * sback, cache_back * cache,
|
||||
int url_savename(char *adr_complete, char *fil_complete, char *save,
|
||||
char *former_adr, char *former_fil, char *referer_adr,
|
||||
char *referer_fil, httrackp * opt, lien_url ** liens,
|
||||
int lien_tot, struct_back * sback, cache_back * cache,
|
||||
hash_struct * hash, int ptr, int numero_passe,
|
||||
const lien_back * headers) {
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
@@ -152,10 +152,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
lien_back *const back = sback->lnk;
|
||||
|
||||
/* */
|
||||
char BIGSTK fil[HTS_URLMAXSIZE * 2]; /* ="" */
|
||||
|
||||
const char *const adr_complete = afs->af.adr;
|
||||
const char *const fil_complete = afs->af.fil;
|
||||
char BIGSTK newfil[HTS_URLMAXSIZE * 2]; /* ="" */
|
||||
|
||||
/*char BIGSTK normadr_[HTS_URLMAXSIZE*2]; */
|
||||
char BIGSTK normadr_[HTS_URLMAXSIZE * 2], normfil_[HTS_URLMAXSIZE * 2];
|
||||
@@ -165,11 +162,12 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
{ "http", "https", "ftp", "file", "unknown" };
|
||||
int protocol = PROTOCOL_HTTP;
|
||||
const char *const adr = jump_identification(adr_complete);
|
||||
char *fil = fil_complete;
|
||||
// copy of fil, used for lookups (see urlhack)
|
||||
const char *normadr = adr;
|
||||
const char *normfil = fil_complete;
|
||||
const char *normfil = fil;
|
||||
const char *const print_adr = jump_protocol(adr);
|
||||
const char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point
|
||||
char *start_pos = NULL, *nom_pos = NULL, *dot_pos = NULL; // Position nom et point
|
||||
|
||||
// pour changement d'extension ou de nom (content-disposition)
|
||||
int ext_chg = 0, ext_chg_delayed = 0;
|
||||
@@ -178,8 +176,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
int max_char = 0;
|
||||
|
||||
//CLEAR
|
||||
fil[0] = ext[0] = '\0';
|
||||
afs->save[0] = '\0';
|
||||
newfil[0] = ext[0] = '\0';
|
||||
save[0] = '\0';
|
||||
|
||||
/* 8-3 ? */
|
||||
switch (opt->savename_83) {
|
||||
@@ -201,7 +199,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
if (opt->urlhack) {
|
||||
// copy of adr (without protocol), used for lookups (see urlhack)
|
||||
normadr = adr_normalized(adr, normadr_);
|
||||
normfil = fil_normalized(fil_complete, normfil_);
|
||||
normfil = fil_normalized(fil, normfil_);
|
||||
} else {
|
||||
if (link_has_authority(adr_complete)) { // https or other protocols : in "http/" subfolder
|
||||
char *pos = strchr(adr_complete, ':');
|
||||
@@ -229,8 +227,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
|
||||
// court-circuit pour lien primaire
|
||||
if (strnotempty(adr) == 0) {
|
||||
if (strcmp(fil_complete, "primary") == 0) {
|
||||
strcatbuff(afs->save, "primary.html");
|
||||
if (strcmp(fil, "primary") == 0) {
|
||||
strcatbuff(save, "primary.html");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -261,21 +259,21 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// vérifier que le nom n'a pas déja été calculé (si oui le renvoyer tel que)
|
||||
// vérifier que le nom n'est pas déja pris...
|
||||
// NOTE: si on cherche /toto/ et que /toto est trouvé on le prend (et réciproquqment) ** // **
|
||||
if (opt->liens != NULL) {
|
||||
if (liens != NULL) {
|
||||
int i;
|
||||
|
||||
i = hash_read(hash, normadr, normfil, HASH_STRUCT_ADR_PATH); // recherche table 1 (adr+fil)
|
||||
if (i >= 0) { // ok, trouvé
|
||||
strcpybuff(afs->save, heap(i)->sav);
|
||||
strcpybuff(save, liens[i]->sav);
|
||||
return 0;
|
||||
}
|
||||
i = hash_read(hash, normadr, normfil, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former->adr+former->fil)
|
||||
i = hash_read(hash, normadr, normfil, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former_adr+former_fil)
|
||||
if (i >= 0) { // ok, trouvé
|
||||
// copier location moved!
|
||||
strcpybuff(afs->af.adr, heap(i)->adr);
|
||||
strcpybuff(afs->af.fil, heap(i)->fil);
|
||||
strcpybuff(adr_complete, liens[i]->adr);
|
||||
strcpybuff(fil_complete, liens[i]->fil);
|
||||
// et save
|
||||
strcpybuff(afs->save, heap(i)->sav); // copier (formé à partir du nouveau lien!)
|
||||
strcpybuff(save, liens[i]->sav); // copier (formé à partir du nouveau lien!)
|
||||
return 0;
|
||||
}
|
||||
// chercher sans / ou avec / dans former
|
||||
@@ -288,13 +286,13 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
fil_complete_patche[strlen(fil_complete_patche) - 1] = '\0';
|
||||
else
|
||||
strcatbuff(fil_complete_patche, "/");
|
||||
i = hash_read(hash, normadr, fil_complete_patche, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former->adr+former->fil)
|
||||
i = hash_read(hash, normadr, fil_complete_patche, HASH_STRUCT_ORIGINAL_ADR_PATH); // recherche table 2 (former_adr+former_fil)
|
||||
if (i >= 0) {
|
||||
// écraser fil et adr (pas former->fil?????)
|
||||
strcpybuff(afs->af.adr, heap(i)->adr);
|
||||
strcpybuff(afs->af.fil, heap(i)->fil);
|
||||
// écraser fil et adr (pas former_fil?????)
|
||||
strcpybuff(adr_complete, liens[i]->adr);
|
||||
strcpybuff(fil_complete, liens[i]->fil);
|
||||
// écrire save
|
||||
strcpybuff(afs->save, heap(i)->sav);
|
||||
strcpybuff(save, liens[i]->sav);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -305,12 +303,13 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
{
|
||||
char *a;
|
||||
|
||||
a = strchr(fil_complete, '?');
|
||||
a = strchr(fil, '?');
|
||||
if (a != NULL) {
|
||||
strncatbuff(fil, fil_complete, a - fil_complete);
|
||||
strncatbuff(newfil, fil, (int) (a - fil));
|
||||
} else {
|
||||
strcpybuff(fil, fil_complete);
|
||||
strcpybuff(newfil, fil);
|
||||
}
|
||||
fil = newfil;
|
||||
}
|
||||
|
||||
// decode remaining % (normally not necessary; already done in htsparse.c)
|
||||
@@ -466,7 +465,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
//
|
||||
int hihp = opt->state._hts_in_html_parsing;
|
||||
int has_been_moved = 0;
|
||||
lien_adrfil current;
|
||||
char BIGSTK curr_adr[HTS_URLMAXSIZE * 2],
|
||||
curr_fil[HTS_URLMAXSIZE * 2];
|
||||
|
||||
/* Ensure we don't use too many sockets by using a "testing" one
|
||||
If we have only 1 simultaneous connection authorized, wait for pending download
|
||||
@@ -475,20 +475,20 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET();
|
||||
|
||||
/* Rock'in */
|
||||
current.adr[0] = current.fil[0] = '\0';
|
||||
curr_adr[0] = curr_fil[0] = '\0';
|
||||
opt->state._hts_in_html_parsing = 2; // test
|
||||
hts_log_print(opt, LOG_DEBUG, "Testing link type %s%s",
|
||||
adr_complete, fil_complete);
|
||||
strcpybuff(current.adr, adr_complete);
|
||||
strcpybuff(current.fil, fil_complete);
|
||||
strcpybuff(curr_adr, adr_complete);
|
||||
strcpybuff(curr_fil, fil_complete);
|
||||
// ajouter dans le backing le fichier en mode test
|
||||
// savename: rien car en mode test
|
||||
if (back_add
|
||||
(sback, opt, cache, current.adr, current.fil, BACK_ADD_TEST,
|
||||
(sback, opt, cache, curr_adr, curr_fil, BACK_ADD_TEST,
|
||||
referer_adr, referer_fil, 1) != -1) {
|
||||
int b;
|
||||
|
||||
b = back_index(opt, sback, current.adr, current.fil, BACK_ADD_TEST);
|
||||
b = back_index(opt, sback, curr_adr, curr_fil, BACK_ADD_TEST);
|
||||
if (b >= 0) {
|
||||
int stop_looping = 0;
|
||||
int petits_tours = 0;
|
||||
@@ -500,7 +500,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
back_wait(sback, opt, cache, 0);
|
||||
}
|
||||
if (ptr >= 0) {
|
||||
back_fillmax(sback, opt, cache, ptr, numero_passe);
|
||||
back_fillmax(sback, opt, cache, liens, ptr, numero_passe,
|
||||
lien_tot);
|
||||
}
|
||||
// on est obligé d'appeler le shell pour le refresh..
|
||||
// Transfer rate
|
||||
@@ -511,11 +512,11 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
HTS_STAT.stat_errors = fspc(opt, NULL, "error");
|
||||
HTS_STAT.stat_warnings = fspc(opt, NULL, "warning");
|
||||
HTS_STAT.stat_infos = fspc(opt, NULL, "info");
|
||||
HTS_STAT.nbk = backlinks_done(sback, opt->liens, opt->lien_tot, ptr);
|
||||
HTS_STAT.nbk = backlinks_done(sback, liens, lien_tot, ptr);
|
||||
HTS_STAT.nb = back_transferred(HTS_STAT.stat_bytes, sback);
|
||||
|
||||
if (!RUN_CALLBACK7
|
||||
(opt, loop, sback->lnk, sback->count, b, ptr, opt->lien_tot,
|
||||
(opt, loop, sback->lnk, sback->count, b, ptr, lien_tot,
|
||||
(int) (time_local() - HTS_STAT.stat_timestart),
|
||||
&HTS_STAT)) {
|
||||
return -1;
|
||||
@@ -526,40 +527,42 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// traitement des 304,303..
|
||||
if (back[b].status <= 0) {
|
||||
if (HTTP_IS_REDIRECT(back[b].r.statuscode)) { // agh moved.. un tit tour de plus
|
||||
if ((petits_tours < 5) && former != NULL) { // on va pas tourner en rond non plus!
|
||||
if (strnotempty(back[b].r.location)) { // location existe!
|
||||
char BIGSTK mov_url[HTS_URLMAXSIZE * 2];
|
||||
lien_adrfil moved;
|
||||
mov_url[0] = moved.adr[0] = moved.fil[0] = '\0';
|
||||
if ((petits_tours < 5) && (former_adr) && (former_fil)) { // on va pas tourner en rond non plus!
|
||||
if ((int) strnotempty(back[b].r.location)) { // location existe!
|
||||
char BIGSTK mov_url[HTS_URLMAXSIZE * 2],
|
||||
mov_adr[HTS_URLMAXSIZE * 2],
|
||||
mov_fil[HTS_URLMAXSIZE * 2];
|
||||
mov_url[0] = mov_adr[0] = mov_fil[0] = '\0';
|
||||
//
|
||||
strcpybuff(mov_url, back[b].r.location); // copier URL
|
||||
if (ident_url_relatif
|
||||
(mov_url, current.adr, current.fil, &moved) >= 0) {
|
||||
(mov_url, curr_adr, curr_fil, mov_adr,
|
||||
mov_fil) >= 0) {
|
||||
// si non bouclage sur soi même, ou si test avec GET non testé
|
||||
if ((strcmp(moved.adr, current.adr))
|
||||
|| (strcmp(moved.fil, current.fil))
|
||||
if ((strcmp(mov_adr, curr_adr))
|
||||
|| (strcmp(mov_fil, curr_fil))
|
||||
|| (get_test_request == 0)) {
|
||||
// bouclage?
|
||||
if ((!strcmp(moved.adr, current.adr))
|
||||
&& (!strcmp(moved.fil, current.fil)))
|
||||
if ((!strcmp(mov_adr, curr_adr))
|
||||
&& (!strcmp(mov_fil, curr_fil)))
|
||||
get_test_request = 1; // faire requète avec GET
|
||||
|
||||
// recopier former->adr/fil?
|
||||
if (former != NULL) {
|
||||
if (strnotempty(former->adr) == 0) { // Pas déja noté
|
||||
strcpybuff(former->adr, current.adr);
|
||||
strcpybuff(former->fil, current.fil);
|
||||
// recopier former_adr/fil?
|
||||
if ((former_adr) && (former_fil)) {
|
||||
if (strnotempty(former_adr) == 0) { // Pas déja noté
|
||||
strcpybuff(former_adr, curr_adr);
|
||||
strcpybuff(former_fil, curr_fil);
|
||||
}
|
||||
}
|
||||
// check explicit forbidden - don't follow 3xx in this case
|
||||
{
|
||||
int set_prio_to = 0;
|
||||
|
||||
if (hts_acceptlink(opt, ptr, moved.adr, moved.fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */
|
||||
if (hts_acceptlink(opt, ptr, lien_tot, liens, mov_adr, mov_fil, NULL, NULL, &set_prio_to, NULL) == 1) { /* forbidden */
|
||||
has_been_moved = 1;
|
||||
back_maydelete(opt, cache, sback, b); // ok
|
||||
strcpybuff(current.adr, moved.adr);
|
||||
strcpybuff(current.fil, moved.fil);
|
||||
strcpybuff(curr_adr, mov_adr);
|
||||
strcpybuff(curr_fil, mov_fil);
|
||||
mov_url[0] = '\0';
|
||||
stop_looping = 1;
|
||||
}
|
||||
@@ -570,11 +573,11 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
) { // ftp, ok on arrête
|
||||
has_been_moved = 1;
|
||||
back_maydelete(opt, cache, sback, b); // ok
|
||||
strcpybuff(current.adr, moved.adr);
|
||||
strcpybuff(current.fil, moved.fil);
|
||||
strcpybuff(curr_adr, mov_adr);
|
||||
strcpybuff(curr_fil, mov_fil);
|
||||
stop_looping = 1;
|
||||
} else if (*mov_url) {
|
||||
const char *methode;
|
||||
char *methode;
|
||||
|
||||
if (!get_test_request)
|
||||
methode = BACK_ADD_TEST; // tester avec HEAD
|
||||
@@ -582,24 +585,24 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
methode = BACK_ADD_TEST2; // tester avec GET
|
||||
hts_log_print(opt, LOG_WARNING,
|
||||
"Loop with HEAD request (during prefetch) at %s%s",
|
||||
current.adr, current.fil);
|
||||
curr_adr, curr_fil);
|
||||
}
|
||||
// Ajouter
|
||||
URLSAVENAME_WAIT_FOR_AVAILABLE_SOCKET();
|
||||
if (back_add(sback, opt, cache, moved.adr, moved.fil, methode, referer_adr, referer_fil, 1) != -1) { // OK
|
||||
if (back_add(sback, opt, cache, mov_adr, mov_fil, methode, referer_adr, referer_fil, 1) != -1) { // OK
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(during prefetch) %s (%d) to link %s at %s%s",
|
||||
back[b].r.msg,
|
||||
back[b].r.statuscode,
|
||||
back[b].r.location, current.adr,
|
||||
current.fil);
|
||||
back[b].r.location, curr_adr,
|
||||
curr_fil);
|
||||
|
||||
// libérer emplacement backing actuel et attendre le prochain
|
||||
back_maydelete(opt, cache, sback, b);
|
||||
strcpybuff(current.adr, moved.adr);
|
||||
strcpybuff(current.fil, moved.fil);
|
||||
strcpybuff(curr_adr, mov_adr);
|
||||
strcpybuff(curr_fil, mov_fil);
|
||||
b =
|
||||
back_index(opt, sback, current.adr, current.fil,
|
||||
back_index(opt, sback, curr_adr, curr_fil,
|
||||
methode);
|
||||
if (!get_test_request)
|
||||
has_been_moved = 1; // sinon ne pas forcer has_been_moved car non déplacé
|
||||
@@ -608,7 +611,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
} else { // sinon on fait rien et on s'en va.. (ftp etc)
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"Warning: Savename redirect backing error at %s%s",
|
||||
moved.adr, moved.fil);
|
||||
mov_adr, mov_fil);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -670,13 +673,13 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// oops, a été déplacé.. on recalcule en récursif (osons!)
|
||||
if (has_been_moved) {
|
||||
// copier adr, fil (optionnel, mais sinon marche pas pour le rip)
|
||||
strcpybuff(afs->af.adr, current.adr);
|
||||
strcpybuff(afs->af.fil, current.fil);
|
||||
strcpybuff(adr_complete, curr_adr);
|
||||
strcpybuff(fil_complete, curr_fil);
|
||||
// copier adr, fil
|
||||
|
||||
return url_savename(afs, NULL,
|
||||
referer_adr, referer_fil, opt,
|
||||
sback, cache, hash, ptr,
|
||||
return url_savename(curr_adr, curr_fil, save, NULL, NULL,
|
||||
referer_adr, referer_fil, opt, liens,
|
||||
lien_tot, sback, cache, hash, ptr,
|
||||
numero_passe, NULL);
|
||||
}
|
||||
// --- --- ---
|
||||
@@ -746,7 +749,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
// Rechercher premier / et dernier .
|
||||
{
|
||||
const char *a = fil + strlen(fil) - 1;
|
||||
char *a = fil + strlen(fil) - 1;
|
||||
|
||||
// passer structures
|
||||
start_pos = fil;
|
||||
@@ -767,7 +770,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// ajouter nom du site éventuellement en premier
|
||||
if (opt->savename_type == -1) { // utiliser savename_userdef! (%h%p/%n%q.%t)
|
||||
const char *a = StringBuff(opt->savename_userdef);
|
||||
char *b = afs->save;
|
||||
char *b = save;
|
||||
|
||||
/*char *nom_pos=NULL,*dot_pos=NULL; // Position nom et point */
|
||||
char tok;
|
||||
@@ -788,7 +791,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
*/
|
||||
|
||||
// Construire nom
|
||||
while((*a) && (((int) (b - afs->save)) < HTS_URLMAXSIZE)) { // parser, et pas trop long..
|
||||
while((*a) && (((int) (b - save)) < HTS_URLMAXSIZE)) { // parser, et pas trop long..
|
||||
if (*a == '%') {
|
||||
int short_ver = 0;
|
||||
|
||||
@@ -1045,26 +1048,26 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
|
||||
// adresse url
|
||||
if (!opt->savename_83) { // noms longs (et pas de .)
|
||||
strcatbuff(afs->save, final_adr);
|
||||
strcatbuff(save, final_adr);
|
||||
} else { // noms 8-3
|
||||
if (strlen(final_adr) > 4) {
|
||||
if (strfield(final_adr, "www."))
|
||||
hts_appendStringUTF8(afs->save, final_adr + 4, max_char);
|
||||
hts_appendStringUTF8(save, final_adr + 4, max_char);
|
||||
else
|
||||
hts_appendStringUTF8(afs->save, final_adr, max_char);
|
||||
hts_appendStringUTF8(save, final_adr, max_char);
|
||||
} else
|
||||
hts_appendStringUTF8(afs->save, final_adr, max_char);
|
||||
hts_appendStringUTF8(save, final_adr, max_char);
|
||||
}
|
||||
|
||||
/* release */
|
||||
RELEASE_ADR();
|
||||
|
||||
if (*fil != '/')
|
||||
strcatbuff(afs->save, "/");
|
||||
strcatbuff(save, "/");
|
||||
}
|
||||
}
|
||||
|
||||
hts_lowcase(afs->save);
|
||||
hts_lowcase(save);
|
||||
|
||||
/*
|
||||
// ne sert à rien car a déja été filtré normalement
|
||||
@@ -1090,42 +1093,42 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
DECLARE_ADR(final_adr);
|
||||
|
||||
if (!opt->savename_83) { // noms longs
|
||||
strcatbuff(afs->save, final_adr);
|
||||
strcatbuff(afs->save, "/");
|
||||
strcatbuff(save, final_adr);
|
||||
strcatbuff(save, "/");
|
||||
} else { // noms 8-3
|
||||
if (strlen(final_adr) > 4) {
|
||||
if (strfield(final_adr, "www."))
|
||||
hts_appendStringUTF8(afs->save, final_adr + 4, max_char);
|
||||
hts_appendStringUTF8(save, final_adr + 4, max_char);
|
||||
else
|
||||
hts_appendStringUTF8(afs->save, final_adr, max_char);
|
||||
strcatbuff(afs->save, "/");
|
||||
hts_appendStringUTF8(save, final_adr, max_char);
|
||||
strcatbuff(save, "/");
|
||||
} else {
|
||||
hts_appendStringUTF8(afs->save, final_adr, max_char);
|
||||
strcatbuff(afs->save, "/");
|
||||
hts_appendStringUTF8(save, final_adr, max_char);
|
||||
strcatbuff(save, "/");
|
||||
}
|
||||
}
|
||||
|
||||
/* release */
|
||||
RELEASE_ADR();
|
||||
} else {
|
||||
strcatbuff(afs->save, "web/"); // répertoire général
|
||||
strcatbuff(save, "web/"); // répertoire général
|
||||
}
|
||||
}
|
||||
// si un html à coup sûr
|
||||
if ((ext_chg != 0) ? (ishtml_ext(ext) == 1) : (ishtml(opt, fil) == 1)) {
|
||||
if (opt->savename_type % 100 == 2) { // html/
|
||||
strcatbuff(afs->save, "html/");
|
||||
strcatbuff(save, "html/");
|
||||
}
|
||||
} else {
|
||||
if ((opt->savename_type % 100 == 1) || (opt->savename_type % 100 == 2)) { // html & images
|
||||
strcatbuff(afs->save, "images/");
|
||||
strcatbuff(save, "images/");
|
||||
}
|
||||
}
|
||||
|
||||
switch (opt->savename_type % 100) {
|
||||
case 4:
|
||||
case 5:{ // séparer par types
|
||||
const char *a = fil + strlen(fil) - 1;
|
||||
char *a = fil + strlen(fil) - 1;
|
||||
|
||||
// passer structures
|
||||
while((a > fil) && (*a != '/') && (*a != '\\'))
|
||||
@@ -1136,17 +1139,17 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// html?
|
||||
if ((ext_chg != 0) ? (ishtml_ext(ext) == 1) : (ishtml(opt, fil) == 1)) {
|
||||
if (opt->savename_type % 100 == 5)
|
||||
strcatbuff(afs->save, "html/");
|
||||
strcatbuff(save, "html/");
|
||||
} else {
|
||||
const char *a = fil + strlen(fil) - 1;
|
||||
char *a = fil + strlen(fil) - 1;
|
||||
|
||||
while((a > fil) && (*a != '/') && (*a != '.'))
|
||||
a--;
|
||||
if (*a != '.')
|
||||
strcatbuff(afs->save, "other");
|
||||
strcatbuff(save, "other");
|
||||
else
|
||||
strcatbuff(afs->save, a + 1);
|
||||
strcatbuff(afs->save, "/");
|
||||
strcatbuff(save, a + 1);
|
||||
strcatbuff(save, "/");
|
||||
}
|
||||
/*strcatbuff(save,a); */
|
||||
/* add name */
|
||||
@@ -1155,8 +1158,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
break;
|
||||
case 99:{ // 'codé' .. c'est un gadget
|
||||
size_t i;
|
||||
size_t j;
|
||||
const char *a;
|
||||
int j;
|
||||
char *a;
|
||||
char C[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
|
||||
int L;
|
||||
|
||||
@@ -1172,19 +1175,19 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
srand(s);
|
||||
|
||||
j = strlen(afs->save);
|
||||
j = (int) strlen(save);
|
||||
for(i = 0; i < 8; i++) {
|
||||
char c = C[(rand() % L)];
|
||||
|
||||
afs->save[i + j] = c;
|
||||
save[i + j] = c;
|
||||
}
|
||||
afs->save[i + j] = '\0';
|
||||
save[i + j] = '\0';
|
||||
// ajouter extension
|
||||
a = fil + strlen(fil) - 1;
|
||||
while((a > fil) && (*a != '/') && (*a != '.'))
|
||||
a--;
|
||||
if (*a == '.') {
|
||||
strcatbuff(afs->save, a); // ajouter
|
||||
strcatbuff(save, a); // ajouter
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1203,10 +1206,10 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
break;
|
||||
}
|
||||
|
||||
hts_lowcase(afs->save);
|
||||
hts_lowcase(save);
|
||||
|
||||
if (afs->save[strlen(afs->save) - 1] == '/')
|
||||
strcatbuff(afs->save, DEFAULT_HTML); // nommer page par défaut!!
|
||||
if (save[strlen(save) - 1] == '/')
|
||||
strcatbuff(save, DEFAULT_HTML); // nommer page par défaut!!
|
||||
}
|
||||
|
||||
// vérifier qu'on ne doit pas forcer l'extension
|
||||
@@ -1224,23 +1227,23 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// de même en cas de manque d'extension on en place une de manière forcée..
|
||||
// cela évite les /chez/toto et les /chez/toto/index.html incompatibles
|
||||
if (opt->savename_type != -1 && opt->savename_delayed != 2) {
|
||||
char *a = afs->save + strlen(afs->save) - 1;
|
||||
char *a = save + strlen(save) - 1;
|
||||
|
||||
while((a > afs->save) && (*a != '.') && (*a != '/'))
|
||||
while((a > save) && (*a != '.') && (*a != '/'))
|
||||
a--;
|
||||
if (*a != '.') { // agh pas de point
|
||||
//strcatbuff(save,".none"); // a éviter
|
||||
strcatbuff(afs->save, ".html"); // préférable!
|
||||
strcatbuff(save, ".html"); // préférable!
|
||||
hts_log_print(opt, LOG_DEBUG, "Default HTML type set for %s%s => %s",
|
||||
adr_complete, fil_complete, afs->save);
|
||||
adr_complete, fil_complete, save);
|
||||
}
|
||||
}
|
||||
// effacer pass au besoin pour les autentifications
|
||||
// (plus la peine : masqué au début)
|
||||
/*
|
||||
{
|
||||
char* a=jump_identification(afs->save);
|
||||
if (a!=afs->save) {
|
||||
char* a=jump_identification(save);
|
||||
if (a!=save) {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE*2];
|
||||
char *b;
|
||||
tempo[0]='\0';
|
||||
@@ -1257,18 +1260,18 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
*/
|
||||
|
||||
// éviter les / au début (cause: N100)
|
||||
if (afs->save[0] == '/') {
|
||||
if (save[0] == '/') {
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(tempo, afs->save + 1);
|
||||
strcpybuff(afs->save, tempo);
|
||||
strcpybuff(tempo, save + 1);
|
||||
strcpybuff(save, tempo);
|
||||
}
|
||||
|
||||
/* Cleanup reserved or forbidden characters. */
|
||||
{
|
||||
size_t i;
|
||||
for(i = 0 ; afs->save[i] != '\0' ; i++) {
|
||||
unsigned char c = (unsigned char) afs->save[i];
|
||||
for(i = 0 ; save[i] != '\0' ; i++) {
|
||||
unsigned char c = (unsigned char) save[i];
|
||||
if (c < 32 // control
|
||||
|| c == 127 // unwise
|
||||
|| c == '~' // unix unwise
|
||||
@@ -1293,13 +1296,13 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
)
|
||||
)
|
||||
{
|
||||
afs->save[i] = '_';
|
||||
save[i] = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// éliminer les // (comme ftp://)
|
||||
cleanDoubleSlash(afs->save);
|
||||
cleanDoubleSlash(save);
|
||||
|
||||
#if HTS_OVERRIDE_DOS_FOLDERS
|
||||
/* Replace /foo/nul/bar by /foo/nul_/bar */
|
||||
@@ -1307,7 +1310,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
int i = 0;
|
||||
|
||||
while(hts_tbdev[i][0]) {
|
||||
char *a = afs->save;
|
||||
char *a = save;
|
||||
|
||||
while((a = strstrcase(a, (char *) hts_tbdev[i]))) {
|
||||
switch ((int) a[strlen(hts_tbdev[i])]) {
|
||||
@@ -1318,10 +1321,10 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
tempo[0] = '\0';
|
||||
strncatbuff(tempo, afs->save, (int) (a - afs->save) + strlen(hts_tbdev[i]));
|
||||
strncatbuff(tempo, save, (int) (a - save) + strlen(hts_tbdev[i]));
|
||||
strcatbuff(tempo, "_");
|
||||
strcatbuff(tempo, a + strlen(hts_tbdev[i]));
|
||||
strcpybuff(afs->save, tempo);
|
||||
strcpybuff(save, tempo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1332,7 +1335,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
|
||||
/* Strip ending . or ' ' forbidden on windoz */
|
||||
cleanEndingSpaceOrDot(afs->save);
|
||||
cleanEndingSpaceOrDot(save);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1340,8 +1343,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
if (opt->savename_83) {
|
||||
char BIGSTK n83[HTS_URLMAXSIZE * 2];
|
||||
|
||||
long_to_83(opt->savename_83, n83, afs->save);
|
||||
strcpybuff(afs->save, n83);
|
||||
long_to_83(opt->savename_83, n83, save);
|
||||
strcpybuff(save, n83);
|
||||
}
|
||||
// enforce stricter ISO9660 compliance (bug reported by Steffo Carlsson)
|
||||
// Level 1 File names are restricted to 8 characters with a 3 character extension,
|
||||
@@ -1352,12 +1355,12 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
if (opt->savename_83 > 0) {
|
||||
char *a, *last;
|
||||
|
||||
for(last = afs->save + strlen(afs->save) - 1;
|
||||
last != afs->save && *last != '/' && *last != '\\' && *last != '.'; last--) ;
|
||||
for(last = save + strlen(save) - 1;
|
||||
last != save && *last != '/' && *last != '\\' && *last != '.'; last--) ;
|
||||
if (*last != '.') {
|
||||
last = NULL;
|
||||
}
|
||||
for(a = afs->save; *a != '\0'; a++) {
|
||||
for(a = save; *a != '\0'; a++) {
|
||||
if (*a >= 'a' && *a <= 'z') {
|
||||
*a -= 'a' - 'A';
|
||||
} else if (*a == '.') {
|
||||
@@ -1374,7 +1377,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
|
||||
/* ensure that there is no ../ (potential vulnerability) */
|
||||
fil_simplifie(afs->save);
|
||||
fil_simplifie(save);
|
||||
|
||||
/* convert name to UTF-8 ? Note: already done while parsing. */
|
||||
//if (charset != NULL && charset[0] != '\0') {
|
||||
@@ -1391,17 +1394,17 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
|
||||
/* callback */
|
||||
RUN_CALLBACK5(opt, savename, adr_complete, fil_complete, referer_adr,
|
||||
referer_fil, afs->save);
|
||||
referer_fil, save);
|
||||
|
||||
hts_log_print(opt, LOG_DEBUG, "engine: save-name: local name: %s%s -> %s",
|
||||
adr, fil, afs->save);
|
||||
adr, fil, save);
|
||||
|
||||
/* Ensure that the MANDATORY "temporary" extension is set */
|
||||
if (ext_chg_delayed) {
|
||||
char *ptr;
|
||||
char *lastDot = NULL;
|
||||
|
||||
for(ptr = afs->save; *ptr != 0; ptr++) {
|
||||
for(ptr = save; *ptr != 0; ptr++) {
|
||||
if (*ptr == '.') {
|
||||
lastDot = ptr;
|
||||
} else if (*ptr == '/' || *ptr == '\\') {
|
||||
@@ -1409,8 +1412,8 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
}
|
||||
if (lastDot == NULL) {
|
||||
strcatbuff(afs->save, "." DELAYED_EXT);
|
||||
} else if (!IS_DELAYED_EXT(afs->save)) {
|
||||
strcatbuff(save, "." DELAYED_EXT);
|
||||
} else if (!IS_DELAYED_EXT(save)) {
|
||||
strcatbuff(lastDot, "." DELAYED_EXT);
|
||||
}
|
||||
}
|
||||
@@ -1423,12 +1426,12 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
#define MIN_LAST_SEG_RESERVE 12
|
||||
#define MAX_LAST_SEG_RESERVE 24
|
||||
#define MAX_SEG_LEN 48
|
||||
if (hts_stringLengthUTF8(afs->save) +
|
||||
if (hts_stringLengthUTF8(save) +
|
||||
hts_stringLengthUTF8(StringBuff(opt->path_html_utf8)) >=
|
||||
HTS_MAX_PATH_LEN) {
|
||||
// convert to Unicode (much simpler)
|
||||
size_t wsaveLen;
|
||||
hts_UCS4 *const wsave = hts_convertUTF8StringToUCS4(afs->save, strlen(afs->save), &wsaveLen);
|
||||
hts_UCS4 *const wsave = hts_convertUTF8StringToUCS4(save, strlen(save), &wsaveLen);
|
||||
if (wsave != NULL) {
|
||||
const size_t parentLen =
|
||||
hts_stringLengthUTF8(StringBuff(opt->path_html_utf8));
|
||||
@@ -1483,7 +1486,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
// copy final name and cleanup
|
||||
saveFinal = hts_convertUCS4StringToUTF8(wsave, j);
|
||||
if (saveFinal != NULL) {
|
||||
strcpybuff(afs->save, saveFinal);
|
||||
strcpybuff(save, saveFinal);
|
||||
free(saveFinal);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR, "Could not revert to UTF-8: %s%s",
|
||||
@@ -1493,13 +1496,13 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
|
||||
// log in debug
|
||||
hts_log_print(opt, LOG_DEBUG, "Too long filename shortened: %s%s => %s",
|
||||
adr_complete, fil_complete, afs->save);
|
||||
adr_complete, fil_complete, save);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR, "Could not read UTF-8: %s", afs->save);
|
||||
hts_log_print(opt, LOG_ERROR, "Could not read UTF-8: %s", save);
|
||||
}
|
||||
|
||||
// Re-check again ending space or dot after cut (see bug #5)
|
||||
cleanEndingSpaceOrDot(afs->save);
|
||||
cleanEndingSpaceOrDot(save);
|
||||
}
|
||||
#undef MAX_UTF8_SEQ_CHARS
|
||||
#undef MIN_LAST_SEG_RESERVE
|
||||
@@ -1510,11 +1513,11 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
|
||||
strcpybuff(tempo, StringBuff(opt->path_html_utf8));
|
||||
strcatbuff(tempo, afs->save);
|
||||
strcpybuff(afs->save, tempo);
|
||||
strcatbuff(tempo, save);
|
||||
strcpybuff(save, tempo);
|
||||
}
|
||||
// vérifier que le nom n'est pas déja pris...
|
||||
if (opt->liens != NULL) {
|
||||
if (liens != NULL) {
|
||||
int nom_ok;
|
||||
|
||||
do {
|
||||
@@ -1528,20 +1531,20 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
printf("\nStart search\n");
|
||||
#endif
|
||||
|
||||
i = hash_read(hash, afs->save, NULL, HASH_STRUCT_FILENAME); // lecture type 0 (sav)
|
||||
i = hash_read(hash, save, NULL, HASH_STRUCT_FILENAME); // lecture type 0 (sav)
|
||||
if (i >= 0) {
|
||||
int sameAdr = (strfield2(heap(i)->adr, normadr) != 0);
|
||||
int sameAdr = (strfield2(liens[i]->adr, normadr) != 0);
|
||||
int sameFil;
|
||||
|
||||
// NO - URL hack is only for stripping // and www.
|
||||
//if (opt->urlhack != 0)
|
||||
// sameFil = ( strfield2(heap(i)->fil, normfil) != 0);
|
||||
// sameFil = ( strfield2(liens[i]->fil, normfil) != 0);
|
||||
//else
|
||||
sameFil = (strcmp(heap(i)->fil, normfil) == 0);
|
||||
sameFil = (strcmp(liens[i]->fil, normfil) == 0);
|
||||
if (sameAdr && sameFil) { // ok c'est le même lien, adresse déja définie
|
||||
/* Take the existing name not to screw up with cAsE sEnSiTiViTy of Linux/Unix */
|
||||
if (strcmp(heap(i)->sav, afs->save) != 0) {
|
||||
strcpybuff(afs->save, heap(i)->sav);
|
||||
if (strcmp(liens[i]->sav, save) != 0) {
|
||||
strcpybuff(save, liens[i]->sav);
|
||||
}
|
||||
i = 0;
|
||||
#if DEBUG_SAVENAME
|
||||
@@ -1549,7 +1552,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
#endif
|
||||
} else { // utilisé par un AUTRE, changer de nom
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
char *a = afs->save + strlen(afs->save) - 1;
|
||||
char *a = save + strlen(save) - 1;
|
||||
char *b;
|
||||
int n = 2;
|
||||
char collisionSeparator = ((opt->savename_83 != 2) ? '-' : '_');
|
||||
@@ -1557,18 +1560,18 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
tempo[0] = '\0';
|
||||
|
||||
#if DEBUG_SAVENAME
|
||||
printf("\nWRONG CASE UNMATCH : \n%s\n%s, REDEFINE\n", heap(i)->fil,
|
||||
printf("\nWRONG CASE UNMATCH : \n%s\n%s, REDEFINE\n", liens[i]->fil,
|
||||
fil_complete);
|
||||
#endif
|
||||
nom_ok = 0;
|
||||
i = 0;
|
||||
|
||||
while((a > afs->save) && (*a != '.') && (*a != '\\') && (*a != '/'))
|
||||
while((a > save) && (*a != '.') && (*a != '\\') && (*a != '/'))
|
||||
a--;
|
||||
if (*a == '.')
|
||||
strncatbuff(tempo, afs->save, a - afs->save);
|
||||
strncatbuff(tempo, save, (int) (a - save));
|
||||
else
|
||||
strcatbuff(tempo, afs->save);
|
||||
strcatbuff(tempo, save);
|
||||
|
||||
// tester la présence d'un -xx (ex: index-2.html -> index-3.html)
|
||||
b = tempo + strlen(tempo) - 1;
|
||||
@@ -1599,7 +1602,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
if (*a == '.')
|
||||
strcatbuff(tempo, a);
|
||||
|
||||
strcpybuff(afs->save, tempo);
|
||||
strcpybuff(save, tempo);
|
||||
|
||||
//printf("switched: %s\n",save);
|
||||
|
||||
@@ -1617,7 +1620,7 @@ int url_savename(lien_adrfilsave *const afs,
|
||||
}
|
||||
|
||||
/* nom avec md5 urilisé partout */
|
||||
void standard_name(char *b, const char *dot_pos, const char *nom_pos, const char *fil,
|
||||
void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete,
|
||||
int short_ver) {
|
||||
char md5[32 + 2];
|
||||
|
||||
@@ -1625,9 +1628,9 @@ void standard_name(char *b, const char *dot_pos, const char *nom_pos, const char
|
||||
/* Nom */
|
||||
if (dot_pos) {
|
||||
if (!short_ver) // Noms longs
|
||||
strncatbuff(b, nom_pos, (dot_pos - nom_pos));
|
||||
strncatbuff(b, nom_pos, (int) (dot_pos - nom_pos));
|
||||
else
|
||||
strncatbuff(b, nom_pos, min(dot_pos - nom_pos, 8));
|
||||
strncatbuff(b, nom_pos, min((int) (dot_pos - nom_pos), 8));
|
||||
} else {
|
||||
if (!short_ver) // Noms longs
|
||||
strcatbuff(b, nom_pos);
|
||||
@@ -1635,7 +1638,7 @@ void standard_name(char *b, const char *dot_pos, const char *nom_pos, const char
|
||||
strncatbuff(b, nom_pos, 8);
|
||||
}
|
||||
/* MD5 - 16 bits */
|
||||
strncatbuff(b, url_md5(md5, fil), 4);
|
||||
strncatbuff(b, url_md5(md5, fil_complete), 4);
|
||||
/* Ext */
|
||||
if (dot_pos) {
|
||||
strcatbuff(b, ".");
|
||||
@@ -1656,11 +1659,11 @@ void standard_name(char *b, const char *dot_pos, const char *nom_pos, const char
|
||||
}
|
||||
|
||||
/* Petit md5 */
|
||||
char *url_md5(char *digest, const char *fil) {
|
||||
char *url_md5(char *digest, char *fil_complete) {
|
||||
char *a;
|
||||
|
||||
digest[0] = '\0';
|
||||
a = strchr(fil, '?');
|
||||
a = strchr(fil_complete, '?');
|
||||
if (a) {
|
||||
if (strlen(a)) {
|
||||
char BIGSTK buff[HTS_URLMAXSIZE * 2];
|
||||
@@ -1675,7 +1678,7 @@ char *url_md5(char *digest, const char *fil) {
|
||||
}
|
||||
|
||||
// interne à url_savename: ajoute une chaîne à une autre avec \ -> /
|
||||
void url_savename_addstr(char *d, const char *s) {
|
||||
void url_savename_addstr(char *d, char *s) {
|
||||
int i = (int) strlen(d);
|
||||
|
||||
while(*s) {
|
||||
|
||||
@@ -80,27 +80,18 @@ typedef struct hash_struct hash_struct;
|
||||
#define HTS_DEF_FWSTRUCT_lien_back
|
||||
typedef struct lien_back lien_back;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
typedef struct lien_adrfil lien_adrfil;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
typedef struct lien_adrfilsave lien_adrfilsave;
|
||||
#endif
|
||||
|
||||
// note: 'headers' can either be null, or incomplete (only r member filled)
|
||||
int url_savename(lien_adrfilsave *const afs,
|
||||
lien_adrfil *const former,
|
||||
const char *referer_adr, const char *referer_fil,
|
||||
httrackp * opt, struct_back * sback, cache_back * cache,
|
||||
int url_savename(char *adr_complete, char *fil_complete, char *save,
|
||||
char *former_adr, char *former_fil, char *referer_adr,
|
||||
char *referer_fil, httrackp * opt, lien_url ** liens,
|
||||
int lien_tot, struct_back * sback, cache_back * cache,
|
||||
hash_struct * hash, int ptr, int numero_passe,
|
||||
const lien_back * headers);
|
||||
void standard_name(char *b, const char *dot_pos, const char *nom_pos,
|
||||
const char *fil_complete,
|
||||
void standard_name(char *b, char *dot_pos, char *nom_pos, char *fil_complete,
|
||||
int short_ver);
|
||||
void url_savename_addstr(char *d, const char *s);
|
||||
char *url_md5(char *digest_buffer, const char *fil_complete);
|
||||
void url_savename_addstr(char *d, char *s);
|
||||
char *url_md5(char *digest_buffer, char *fil_complete);
|
||||
void url_savename_refname(const char *adr, const char *fil, char *filename);
|
||||
char *url_savename_refname_fullpath(httrackp * opt, const char *adr,
|
||||
const char *fil);
|
||||
|
||||
@@ -40,7 +40,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#include "htsbasenet.h"
|
||||
#include "htssafe.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#ifdef _WIN32
|
||||
// pour read
|
||||
|
||||
11
src/htsopt.h
11
src/htsopt.h
@@ -274,11 +274,6 @@ typedef enum htsparsejava_flags {
|
||||
HTSPARSE_NO_AGGRESSIVE = 8 // don't aggressively parse .js or .java
|
||||
} htsparsejava_flags;
|
||||
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_buffers
|
||||
#define HTS_DEF_FWSTRUCT_lien_buffers
|
||||
typedef struct lien_buffers lien_buffers;
|
||||
#endif
|
||||
|
||||
// paramètres httrack (options)
|
||||
#ifndef HTS_DEF_FWSTRUCT_httrackp
|
||||
#define HTS_DEF_FWSTRUCT_httrackp
|
||||
@@ -367,9 +362,7 @@ struct httrackp {
|
||||
String urllist; // fichier liste de filtres à inclure
|
||||
htsfilters filters; // contient les pointeurs pour les filtres
|
||||
hash_struct *hash; // hash structure
|
||||
lien_url **liens; // links
|
||||
int lien_tot; // top index of "links" heap (always out-of-range)
|
||||
lien_buffers *liensbuf; // links buffers
|
||||
lien_url **liens; // liens
|
||||
robots_wizard *robotsptr; // robots ptr
|
||||
String lang_iso; // en, fr ..
|
||||
String accept; // Accept:
|
||||
@@ -381,7 +374,7 @@ struct httrackp {
|
||||
int maxlink; // nombre max de liens
|
||||
int maxfilter; // nombre max de filtres
|
||||
//
|
||||
const char *exec; // adresse du nom de l'éxecutable
|
||||
char *exec; // adresse du nom de l'éxecutable
|
||||
//
|
||||
int quiet; // poser des questions autres que wizard?
|
||||
int keyboard; // vérifier stdin
|
||||
|
||||
1365
src/htsparse.c
1365
src/htsparse.c
File diff suppressed because it is too large
Load Diff
@@ -66,7 +66,7 @@ struct htsmoduleStructExtended {
|
||||
char ***filters_;
|
||||
robots_wizard *robots_;
|
||||
hash_struct *hash_;
|
||||
//int *lien_max_;
|
||||
int *lien_max_;
|
||||
|
||||
/* Base & codebase */
|
||||
char *base;
|
||||
@@ -135,13 +135,14 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct * str,
|
||||
to be ready for naming, having its header MIME type
|
||||
If the final URL is to be forbidden, sets 'forbidden_url' to the corresponding value
|
||||
*/
|
||||
int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs,
|
||||
char *parent_adr, char *parent_fil, lien_adrfil *former,
|
||||
int *forbidden_url);
|
||||
int hts_wait_delayed(htsmoduleStruct * str, char *adr, char *fil, char *save,
|
||||
char *parent_adr, char *parent_fil, char *former_adr,
|
||||
char *former_fil, int *forbidden_url);
|
||||
|
||||
/* Context state */
|
||||
|
||||
#define ENGINE_DEFINE_CONTEXT_BASE() \
|
||||
lien_url** const liens HTS_UNUSED = (lien_url**) str->liens; \
|
||||
httrackp* const opt HTS_UNUSED = (httrackp*) str->opt; \
|
||||
struct_back* const sback HTS_UNUSED = (struct_back*) str->sback; \
|
||||
lien_back* const back HTS_UNUSED = sback->lnk; \
|
||||
@@ -149,18 +150,28 @@ int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs,
|
||||
cache_back* const cache HTS_UNUSED = (cache_back*) str->cache; \
|
||||
hash_struct* const hashptr HTS_UNUSED = (hash_struct*) str->hashptr; \
|
||||
const int numero_passe HTS_UNUSED = str->numero_passe; \
|
||||
const int add_tab_alloc HTS_UNUSED = str->add_tab_alloc; \
|
||||
/* variable */ \
|
||||
int ptr = *str->ptr_
|
||||
int lien_tot = *str->lien_tot_; \
|
||||
int ptr = *str->ptr_; \
|
||||
size_t lien_size = *str->lien_size_; \
|
||||
char* lien_buffer = *str->lien_buffer_
|
||||
|
||||
#define ENGINE_SET_CONTEXT_BASE() \
|
||||
ptr = *str->ptr_
|
||||
lien_tot = *str->lien_tot_; \
|
||||
ptr = *str->ptr_; \
|
||||
lien_size = *str->lien_size_; \
|
||||
lien_buffer = *str->lien_buffer_
|
||||
|
||||
#define ENGINE_LOAD_CONTEXT_BASE() \
|
||||
ENGINE_DEFINE_CONTEXT_BASE()
|
||||
|
||||
#define ENGINE_SAVE_CONTEXT_BASE() \
|
||||
/* Apply changes */ \
|
||||
* str->ptr_ = ptr
|
||||
* str->lien_tot_ = lien_tot; \
|
||||
* str->ptr_ = ptr; \
|
||||
* str->lien_size_ = lien_size; \
|
||||
* str->lien_buffer_ = lien_buffer
|
||||
|
||||
#define WAIT_FOR_AVAILABLE_SOCKET() do { \
|
||||
int prev = opt->state._hts_in_html_parsing; \
|
||||
@@ -175,10 +186,10 @@ int hts_wait_delayed(htsmoduleStruct * str, lien_adrfilsave *afs,
|
||||
HTS_STAT.stat_errors=fspc(opt,NULL,"error"); \
|
||||
HTS_STAT.stat_warnings=fspc(opt,NULL,"warning"); \
|
||||
HTS_STAT.stat_infos=fspc(opt,NULL,"info"); \
|
||||
HTS_STAT.nbk=backlinks_done(sback,opt->liens,opt->lien_tot,ptr); \
|
||||
HTS_STAT.nbk=backlinks_done(sback,liens,lien_tot,ptr); \
|
||||
HTS_STAT.nb=back_transferred(HTS_STAT.stat_bytes,sback); \
|
||||
/* Check */ \
|
||||
if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, -1,ptr,opt->lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \
|
||||
if (!RUN_CALLBACK7(opt, loop, sback->lnk, sback->count, -1,ptr,lien_tot,(int) (time_local()-HTS_STAT.stat_timestart),&HTS_STAT)) { \
|
||||
return -1; \
|
||||
} \
|
||||
} \
|
||||
|
||||
@@ -45,7 +45,7 @@ Please visit our Website: http://www.httrack.com
|
||||
// -- robots --
|
||||
|
||||
// fil="" : vérifier si règle déja enregistrée
|
||||
int checkrobots(robots_wizard * robots, const char *adr, const char *fil) {
|
||||
int checkrobots(robots_wizard * robots, char *adr, char *fil) {
|
||||
while(robots) {
|
||||
if (strfield2(robots->adr, adr)) {
|
||||
if (fil[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;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ int checkrobots(robots_wizard * robots, const char *adr, const char *fil) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int checkrobots_set(robots_wizard * robots, const char *adr, const char *data) {
|
||||
int checkrobots_set(robots_wizard * robots, char *adr, char *data) {
|
||||
if (((int) strlen(adr)) >= sizeof(robots->adr) - 2)
|
||||
return 0;
|
||||
if (((int) strlen(data)) >= sizeof(robots->token) - 2)
|
||||
|
||||
@@ -47,9 +47,9 @@ struct robots_wizard {
|
||||
|
||||
/* Library internal definictions */
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
int checkrobots(robots_wizard * robots, const char *adr, const char *fil);
|
||||
int checkrobots(robots_wizard * robots, char *adr, char *fil);
|
||||
void checkrobots_free(robots_wizard * robots);
|
||||
int checkrobots_set(robots_wizard * robots, const char *adr, const char *data);
|
||||
int checkrobots_set(robots_wizard * robots, char *adr, char *data);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -81,7 +81,7 @@ inthash NewLangList = NULL;
|
||||
|
||||
#include "htsserver.h"
|
||||
|
||||
const char *gethomedir(void);
|
||||
char *gethomedir(void);
|
||||
int commandRunning = 0;
|
||||
int commandEndRequested = 0;
|
||||
int commandEnd = 0;
|
||||
@@ -97,13 +97,13 @@ extern void webhttrack_main(char *cmd);
|
||||
extern void webhttrack_lock(void);
|
||||
extern void webhttrack_release(void);
|
||||
|
||||
static int is_image(const char *file) {
|
||||
static int is_image(char *file) {
|
||||
return ((strstr(file, ".gif") != NULL));
|
||||
}
|
||||
static int is_text(const char *file) {
|
||||
static int is_text(char *file) {
|
||||
return ((strstr(file, ".txt") != NULL));
|
||||
}
|
||||
static int is_html(const char *file) {
|
||||
static int is_html(char *file) {
|
||||
return ((strstr(file, ".htm") != NULL));
|
||||
}
|
||||
|
||||
@@ -287,12 +287,12 @@ T_SOC smallserver_init(int *port, char *adr) {
|
||||
// data: 32Kb
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
char *name;
|
||||
int value;
|
||||
} initIntElt;
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *value;
|
||||
char *name;
|
||||
char *value;
|
||||
} initStrElt;
|
||||
|
||||
#define SET_ERROR(err) do { \
|
||||
@@ -326,10 +326,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
{
|
||||
char pth[1024];
|
||||
|
||||
const char *initOn[] = { "parseall", "Cache", "ka",
|
||||
char *initOn[] = { "parseall", "Cache", "ka",
|
||||
"cookies", "parsejava", "testall", "updhack", "urlhack", "index", NULL
|
||||
};
|
||||
const initIntElt initInt[] = {
|
||||
initIntElt initInt[] = {
|
||||
{"filter", 4},
|
||||
{"travel", 2},
|
||||
{"travel2", 1},
|
||||
@@ -383,7 +383,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
char line2[1024];
|
||||
T_SOC soc_c;
|
||||
LLint length = 0;
|
||||
const char *error_redirect = NULL;
|
||||
char *error_redirect = NULL;
|
||||
|
||||
line[0] = '\0';
|
||||
buffer[0] = '\0';
|
||||
@@ -498,7 +498,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
strcatbuff(buffer, "&");
|
||||
while(s && (e = strchr(s, '=')) && (f = strchr(s, '&'))) {
|
||||
const char *ua;
|
||||
char *ua;
|
||||
String sua = STRING_EMPTY;
|
||||
|
||||
*e = *f = '\0';
|
||||
@@ -786,7 +786,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
if (url && *++url == '/' && (pos = strchr(url, ' ')) && !(*pos = '\0')) {
|
||||
char fsfile[1024];
|
||||
const char *file;
|
||||
char *file;
|
||||
FILE *fp;
|
||||
char *qpos;
|
||||
|
||||
@@ -861,10 +861,10 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
"HTTP/1.0 302 Redirect\r\n" "Connection: close\r\n"
|
||||
"Server: httrack-small-server\r\n";
|
||||
intptr_t adr = 0;
|
||||
const char *newfile = file;
|
||||
char *newfile = file;
|
||||
|
||||
if (inthash_readptr(NewLangList, "redirect", &adr) && adr != 0) {
|
||||
const char *newadr = (char *) adr;
|
||||
char *newadr = (char *) adr;
|
||||
|
||||
if (*newadr) {
|
||||
newfile = newadr;
|
||||
@@ -939,7 +939,6 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
}
|
||||
} else if ((p = strfield(name, "do:"))) {
|
||||
char *pos2;
|
||||
char empty[2] = "";
|
||||
|
||||
name += p;
|
||||
format = 1;
|
||||
@@ -949,7 +948,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
*pos2 = '\0';
|
||||
pos2++;
|
||||
} else {
|
||||
pos2 = empty;
|
||||
pos2 = "";
|
||||
}
|
||||
if (strcmp(name, "output-mode") == 0) {
|
||||
if (strcmp(pos2, "html") == 0) {
|
||||
@@ -1064,7 +1063,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
if (pos2 != NULL) {
|
||||
*pos2 = '\0';
|
||||
if (inthash_readptr(NewLangList, name, &adr) || ztest) {
|
||||
const char *newadr = (char *) adr;
|
||||
char *newadr = (char *) adr;
|
||||
|
||||
if (!newadr)
|
||||
newadr = "";
|
||||
@@ -1470,7 +1469,7 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
|
||||
/* Load master file (list of keys and internal keys) */
|
||||
if (!limit_to) {
|
||||
const char *mname = "lang.def";
|
||||
char *mname = "lang.def";
|
||||
FILE *fp = fopen(fconcat(catbuff, sizeof(catbuff), path, mname), "rb");
|
||||
|
||||
if (fp) {
|
||||
@@ -1497,9 +1496,11 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
|
||||
if (!strnotempty(test)) { // éviter doublons
|
||||
// conv_printf(key,key);
|
||||
const size_t len = strlen(intkey);
|
||||
char *const buff = (char *) malloc(len + 1);
|
||||
int len;
|
||||
char *buff;
|
||||
|
||||
len = (int) strlen(intkey);
|
||||
buff = (char *) malloc(len + 2);
|
||||
if (buff) {
|
||||
strcpybuff(buff, intkey);
|
||||
inthash_add(NewLangStrKeys, key, (intptr_t) buff);
|
||||
@@ -1559,6 +1560,8 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
linput_cpp(fp, extkey, 8000);
|
||||
linput_cpp(fp, value, 8000);
|
||||
if (strnotempty(extkey) && strnotempty(value)) {
|
||||
int len;
|
||||
char *buff;
|
||||
const char *intkey;
|
||||
|
||||
intkey = LANGINTKEY(extkey);
|
||||
@@ -1595,8 +1598,8 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
|
||||
/* Add key */
|
||||
if (strnotempty(intkey)) {
|
||||
const size_t len = strlen(value);
|
||||
char *const buff = (char *) malloc(len + 1);
|
||||
len = (int) strlen(value);
|
||||
buff = (char *) malloc(len + 2);
|
||||
if (buff) {
|
||||
conv_printf(value, buff);
|
||||
inthash_add(NewLangStr, intkey, (intptr_t) buff);
|
||||
@@ -1730,7 +1733,7 @@ static int LANG_SEARCH(const char *path, const char *iso) {
|
||||
return found;
|
||||
}
|
||||
|
||||
static int LANG_LIST(const char *path, char *buffer, size_t buffer_size) {
|
||||
static int LANG_LIST(const char *path, char *buffer, size_t size) {
|
||||
char lang_str[1024];
|
||||
int i = 0;
|
||||
int curr_lng = LANG_T(path, -1);
|
||||
@@ -1738,12 +1741,12 @@ static int LANG_LIST(const char *path, char *buffer, size_t buffer_size) {
|
||||
buffer[0] = '\0';
|
||||
do {
|
||||
QLANG_T(i);
|
||||
strlcpybuff(lang_str, "LANGUAGE_NAME", buffer_size);
|
||||
strlcpybuff(lang_str, "LANGUAGE_NAME", size);
|
||||
htslang_load(lang_str, path);
|
||||
if (strlen(lang_str) > 0) {
|
||||
if (buffer[0])
|
||||
strcatbuff(buffer, "\n");
|
||||
strlcatbuff(buffer, lang_str, buffer_size);
|
||||
strcatbuff(buffer, lang_str);
|
||||
}
|
||||
i++;
|
||||
} while(strlen(lang_str) > 0);
|
||||
|
||||
@@ -100,7 +100,7 @@ int htslang_uninit(void);
|
||||
|
||||
/* Static definitions */
|
||||
|
||||
HTS_UNUSED static const char *gethomedir(void);
|
||||
HTS_UNUSED static char *gethomedir(void);
|
||||
HTS_UNUSED static int linput_cpp(FILE * fp, char *s, int max);
|
||||
HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max);
|
||||
HTS_UNUSED static int fexist(const char *s);
|
||||
@@ -163,8 +163,8 @@ HTS_UNUSED static int linputsoc_t(T_SOC soc, char *s, int max, int timeout) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *gethomedir(void) {
|
||||
const char *home = getenv("HOME");
|
||||
static char *gethomedir(void) {
|
||||
char *home = getenv("HOME");
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
@@ -228,7 +228,7 @@ static int linput(FILE * fp, char *s, int max) {
|
||||
}
|
||||
static int linput_trim(FILE * fp, char *s, int max) {
|
||||
int rlen = 0;
|
||||
char *ls = (char *) malloc(max + 1);
|
||||
char *ls = (char *) malloc(max + 2);
|
||||
|
||||
s[0] = '\0';
|
||||
if (ls) {
|
||||
@@ -267,11 +267,11 @@ static int ehexh(char c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ehex(const char *s) {
|
||||
static int ehex(char *s) {
|
||||
return 16 * ehexh(*s) + ehexh(*(s + 1));
|
||||
}
|
||||
|
||||
HTS_UNUSED static void unescapehttp(const char *s, String * tempo) {
|
||||
HTS_UNUSED static void unescapehttp(char *s, String * tempo) {
|
||||
size_t i;
|
||||
|
||||
for(i = 0; s[i] != '\0'; i++) {
|
||||
|
||||
198
src/htstools.c
198
src/htstools.c
@@ -91,11 +91,11 @@ static int ehexh(char c) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ehex(const char *s) {
|
||||
static int ehex(char *s) {
|
||||
return 16 * ehexh(*s) + ehexh(*(s + 1));
|
||||
}
|
||||
|
||||
static void unescapehttp(const char *s, String * tempo) {
|
||||
static void unescapehttp(char *s, String * tempo) {
|
||||
size_t i;
|
||||
|
||||
for(i = 0; s[i] != '\0'; i++) {
|
||||
@@ -122,15 +122,12 @@ static void unescapehttp(const char *s, String * tempo) {
|
||||
// -1 : erreur
|
||||
// -2 : protocole non supporté (ftp)
|
||||
int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
const char *origin_fil,
|
||||
lien_adrfil* const adrfil) {
|
||||
const char *origin_fil, char *adr, char *fil) {
|
||||
int ok = 0;
|
||||
int scheme = 0;
|
||||
|
||||
assertf(adrfil != NULL);
|
||||
|
||||
adrfil->adr[0] = '\0';
|
||||
adrfil->fil[0] = '\0'; //effacer buffers
|
||||
adr[0] = '\0';
|
||||
fil[0] = '\0'; //effacer buffers
|
||||
|
||||
// lien non vide!
|
||||
if (strnotempty(lien) == 0)
|
||||
@@ -152,13 +149,13 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
|| (strfield(lien, "file://")) // scheme+//
|
||||
|| (strncmp(lien, "//", 2) == 0) // // sans scheme (-> default)
|
||||
) {
|
||||
if (ident_url_absolute(lien, adrfil) == -1) {
|
||||
if (ident_url_absolute(lien, adr, fil) == -1) {
|
||||
ok = -1; // erreur URL
|
||||
}
|
||||
} else if (strfield(lien, "ftp://")) {
|
||||
// Note: ftp:foobar.gif is not valid
|
||||
if (ftp_available()) { // ftp supporté
|
||||
if (ident_url_absolute(lien, adrfil) == -1) {
|
||||
if (ident_url_absolute(lien, adr, fil) == -1) {
|
||||
ok = -1; // erreur URL
|
||||
}
|
||||
} else {
|
||||
@@ -167,7 +164,7 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
#if HTS_USEOPENSSL
|
||||
} else if (strfield(lien, "https://")) {
|
||||
// Note: ftp:foobar.gif is not valid
|
||||
if (ident_url_absolute(lien, adrfil) == -1) {
|
||||
if (ident_url_absolute(lien, adr, fil) == -1) {
|
||||
ok = -1; // erreur URL
|
||||
}
|
||||
#endif
|
||||
@@ -194,30 +191,30 @@ 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(adr, jump_protocol(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));
|
||||
strcpybuff(adr, "https://"); // même adresse forcée en https
|
||||
strcatbuff(adr, jump_protocol(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));
|
||||
strcpybuff(adr, "ftp://"); // même adresse forcée en ftp
|
||||
strcatbuff(adr, jump_protocol(origin_adr));
|
||||
} else {
|
||||
strcpybuff(adrfil->adr, origin_adr); // même adresse ; et même éventuel protocole
|
||||
strcpybuff(adr, origin_adr); // même adresse ; et même éventuel protocole
|
||||
}
|
||||
|
||||
if (*lien != '/') { // sinon c'est un lien absolu
|
||||
if (*lien == '\0') {
|
||||
strcpybuff(adrfil->fil, origin_fil);
|
||||
strcpybuff(fil, origin_fil);
|
||||
} else if (*lien == '?') { // example: a href="?page=2"
|
||||
char *a;
|
||||
|
||||
strcpybuff(adrfil->fil, origin_fil);
|
||||
a = strchr(adrfil->fil, '?');
|
||||
strcpybuff(fil, origin_fil);
|
||||
a = strchr(fil, '?');
|
||||
if (a)
|
||||
*a = '\0';
|
||||
strcatbuff(adrfil->fil, lien);
|
||||
strcatbuff(fil, lien);
|
||||
} else {
|
||||
const char *a = strchr(origin_fil, '?');
|
||||
|
||||
@@ -228,14 +225,14 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
if (*a == '/') { // ok on a un '/'
|
||||
if ((((int) (a - origin_fil)) + 1 + strlen(lien)) < HTS_URLMAXSIZE) {
|
||||
// copier chemin
|
||||
strncpy(adrfil->fil, origin_fil, ((int) (a - origin_fil)) + 1);
|
||||
*(adrfil->fil + ((int) (a - origin_fil)) + 1) = '\0';
|
||||
strncpy(fil, origin_fil, ((int) (a - origin_fil)) + 1);
|
||||
*(fil + ((int) (a - origin_fil)) + 1) = '\0';
|
||||
|
||||
// copier chemin relatif
|
||||
if (((int) strlen(adrfil->fil) + (int) strlen(lien)) < HTS_URLMAXSIZE) {
|
||||
strcatbuff(adrfil->fil, lien + ((*lien == '/') ? 1 : 0));
|
||||
if (((int) strlen(fil) + (int) strlen(lien)) < HTS_URLMAXSIZE) {
|
||||
strcatbuff(fil, lien + ((*lien == '/') ? 1 : 0));
|
||||
// simplifier url pour les ../
|
||||
fil_simplifie(adrfil->fil);
|
||||
fil_simplifie(fil);
|
||||
} else
|
||||
ok = -1; // erreur
|
||||
} else { // erreur
|
||||
@@ -247,8 +244,8 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
}
|
||||
} else { // chemin absolu
|
||||
// copier chemin directement
|
||||
strcatbuff(adrfil->fil, lien);
|
||||
fil_simplifie(adrfil->fil);
|
||||
strcatbuff(fil, lien);
|
||||
fil_simplifie(fil);
|
||||
} // *lien!='/'
|
||||
} else
|
||||
ok = -1;
|
||||
@@ -257,7 +254,7 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
|
||||
// case insensitive pour adresse
|
||||
{
|
||||
char *a = jump_identification(adrfil->adr);
|
||||
char *a = jump_identification(adr);
|
||||
|
||||
while(*a) {
|
||||
if ((*a >= 'A') && (*a <= 'Z'))
|
||||
@@ -267,8 +264,8 @@ int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
}
|
||||
|
||||
// IDNA / RFC 3492 (Punycode) handling for HTTP(s)
|
||||
if (!link_has_authority(adrfil->adr) || strfield(adrfil->adr, "https:")) {
|
||||
char *const a = jump_identification(adrfil->adr);
|
||||
if (!link_has_authority(adr) || strfield(adr, "https:")) {
|
||||
char *const a = jump_identification(adr);
|
||||
// Non-ASCII characters (theorically forbidden, but browsers are lenient)
|
||||
if (!hts_isStringAscii(a, strlen(a))) {
|
||||
char *const idna = hts_convertStringUTF8ToIDNA(a, strlen(a));
|
||||
@@ -711,18 +708,19 @@ HTS_INLINE int rech_sampletag(const char *adr, const char *s) {
|
||||
}
|
||||
|
||||
// teste si le tag contenu dans from est égal à "tag"
|
||||
HTS_INLINE int check_tag(const char *from, const char *tag) {
|
||||
const char *a = from + 1;
|
||||
HTS_INLINE int check_tag(char *from, const char *tag) {
|
||||
char *a = from + 1;
|
||||
int i = 0;
|
||||
char s[256];
|
||||
|
||||
while(is_space(*a))
|
||||
a++;
|
||||
for( ; (isalnum((unsigned char) *a) || (*a == '/')) && i + 1 < sizeof(s) ; i++, a++) {
|
||||
s[i] = *a;
|
||||
while((isalnum((unsigned char) *a) || (*a == '/')) && (i < 250)) {
|
||||
s[i++] = *a;
|
||||
a++;
|
||||
}
|
||||
s[i] = '\0';
|
||||
return strfield2(s, tag); // comparer
|
||||
s[i++] = '\0';
|
||||
return (strfield2(s, tag)); // comparer
|
||||
}
|
||||
|
||||
// teste si un fichier dépasse le quota
|
||||
@@ -760,117 +758,7 @@ static int sortTopIndexFnc(const void *a_, const void *b_) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
typedef struct hts_template_format_buf {
|
||||
FILE *fp;
|
||||
char *buffer;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
} hts_template_format_buf;
|
||||
|
||||
// note: upstream arg list MUST be NULL-terminated for safety
|
||||
// returns a negative value upon error
|
||||
static int hts_template_formatv(hts_template_format_buf *buf,
|
||||
const char *format, va_list args) {
|
||||
#undef FPUTC
|
||||
#undef FPUTS
|
||||
#define FPUTC(C) do { \
|
||||
if (buf->fp != NULL) { \
|
||||
assertf(buf->buffer == NULL); \
|
||||
if (fputc(C, buf->fp) < 0) { \
|
||||
return -1; \
|
||||
} \
|
||||
} else { \
|
||||
assertf(buf->buffer != NULL); \
|
||||
if (buf->offset + 1 < buf->size) { \
|
||||
buf->buffer[buf->offset++] = (C); \
|
||||
} else { \
|
||||
return -1; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
#define FPUTS(S) do { \
|
||||
size_t i; \
|
||||
const char *const str_ = (S); \
|
||||
assertf(str_ != NULL); \
|
||||
for(i = 0 ; str_[i] != '\0' ; i++) { \
|
||||
FPUTC(str_[i]); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
if (buf != NULL && format != NULL) {
|
||||
const char *arg_expanded[32];
|
||||
size_t i, nbArgs, posArgs;
|
||||
/* Expand internal code args. */
|
||||
const char *str;
|
||||
for(nbArgs = 0 ; ( str = va_arg(args, const char*) ) != NULL ; nbArgs++) {
|
||||
assertf(nbArgs < sizeof(arg_expanded)/sizeof(arg_expanded[0]));
|
||||
arg_expanded[nbArgs] = str;
|
||||
}
|
||||
/* Expand user-injected format string. */
|
||||
for(posArgs = 0, i = 0 ; format[i] != '\0' ; i++) {
|
||||
const unsigned char c = format[i];
|
||||
if (c == '%') {
|
||||
const unsigned char cFormat = format[++i];
|
||||
switch(cFormat) {
|
||||
case '%':
|
||||
FPUTC('%');
|
||||
break;
|
||||
case 's':
|
||||
if (posArgs < nbArgs) {
|
||||
assertf(arg_expanded[posArgs] != NULL);
|
||||
FPUTS(arg_expanded[posArgs]);
|
||||
posArgs++;
|
||||
} else {
|
||||
FPUTS("???"); /* error (args overflow) */
|
||||
}
|
||||
break;
|
||||
default: /* ignored */
|
||||
FPUTC('%');
|
||||
FPUTC(cFormat);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
FPUTC(c);
|
||||
}
|
||||
}
|
||||
/* Terminating NULL. */
|
||||
if (buf->buffer != NULL) {
|
||||
buf->buffer[buf->offset] = 0;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
#undef FPUTC
|
||||
#undef FPUTS
|
||||
}
|
||||
|
||||
// note: upstream arg list MUST be NULL-terminated for safety
|
||||
// returns a negative value upon error
|
||||
int hts_template_format(FILE *const out, const char *format, ...) {
|
||||
int success;
|
||||
hts_template_format_buf buf = { NULL, NULL, 0, 0 };
|
||||
va_list args;
|
||||
buf.fp = out;
|
||||
va_start(args, format);
|
||||
success = hts_template_formatv(&buf, format, args);
|
||||
va_end(args);
|
||||
return success;
|
||||
}
|
||||
|
||||
// note: upstream arg list MUST be NULL-terminated for safety
|
||||
// returns a negative value upon error
|
||||
int hts_template_format_str(char *buffer, size_t size, const char *format, ...) {
|
||||
int success;
|
||||
hts_template_format_buf buf = { NULL, NULL, 0, 0 };
|
||||
va_list args;
|
||||
buf.buffer = buffer;
|
||||
buf.size = size;
|
||||
va_start(args, format);
|
||||
success = hts_template_formatv(&buf, format, args);
|
||||
va_end(args);
|
||||
return success;
|
||||
}
|
||||
//HTSEXT_API char *hts_getcategory(const char *filename);
|
||||
|
||||
/* Note: NOT utf-8 */
|
||||
HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path,
|
||||
@@ -911,9 +799,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path,
|
||||
|
||||
verif_backblue(opt, concat(catbuff, sizeof(catbuff), rpath, "/")); // générer gif
|
||||
// Header
|
||||
hts_template_format(fpo, toptemplate_header,
|
||||
fprintf(fpo, toptemplate_header,
|
||||
"<!-- Mirror and index made by HTTrack Website Copier/"
|
||||
HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->", /* EOF */ NULL);
|
||||
HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->");
|
||||
|
||||
/* Find valid project names */
|
||||
h = hts_findfirst(rpath);
|
||||
@@ -982,7 +870,7 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path,
|
||||
assertf(sortedElts != NULL);
|
||||
if (sortedElts != NULL) {
|
||||
int i;
|
||||
const char *category = "";
|
||||
char *category = "";
|
||||
|
||||
/* Build array */
|
||||
struct topindex_chain *chain = startchain;
|
||||
@@ -1004,9 +892,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path,
|
||||
/* Changed category */
|
||||
if (strcmp(category, sortedElts[i]->category) != 0) {
|
||||
category = sortedElts[i]->category;
|
||||
hts_template_format(fpo, toptemplate_bodycat, category, /* EOF */ NULL);
|
||||
fprintf(fpo, toptemplate_bodycat, category);
|
||||
}
|
||||
hts_template_format(fpo, toptemplate_body, hname, sortedElts[i]->name, /* EOF */ NULL);
|
||||
fprintf(fpo, toptemplate_body, hname, sortedElts[i]->name);
|
||||
}
|
||||
|
||||
/* Wipe elements */
|
||||
@@ -1024,9 +912,9 @@ HTSEXT_API int hts_buildtopindex(httrackp * opt, const char *path,
|
||||
|
||||
}
|
||||
// Footer
|
||||
hts_template_format(fpo, toptemplate_footer,
|
||||
fprintf(fpo, toptemplate_footer,
|
||||
"<!-- Mirror and index made by HTTrack Website Copier/"
|
||||
HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->", /* EOF */ NULL);
|
||||
HTTRACK_VERSION " " HTTRACK_AFF_AUTHORS " -->");
|
||||
|
||||
fclose(fpo);
|
||||
|
||||
|
||||
@@ -47,20 +47,11 @@ typedef struct httrackp httrackp;
|
||||
typedef struct find_handle_struct find_handle_struct;
|
||||
typedef find_handle_struct *find_handle;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfil
|
||||
typedef struct lien_adrfil lien_adrfil;
|
||||
#endif
|
||||
#ifndef HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
#define HTS_DEF_FWSTRUCT_lien_adrfilsave
|
||||
typedef struct lien_adrfilsave lien_adrfilsave;
|
||||
#endif
|
||||
|
||||
/* Library internal definictions */
|
||||
#ifdef HTS_INTERNAL_BYTECODE
|
||||
int ident_url_relatif(const char *lien, const char *origin_adr,
|
||||
const char *origin_fil,
|
||||
lien_adrfil* const adrfil);
|
||||
int ident_url_relatif(const char *lien, const char *urladr, const char *urlfil,
|
||||
char *adr, char *fil);
|
||||
int lienrelatif(char *s, const char *link, const char *curr);
|
||||
int link_has_authority(const char *lien);
|
||||
int link_has_authorization(const char *lien);
|
||||
@@ -70,9 +61,6 @@ HTS_INLINE int __rech_tageq(const char *adr, const char *s);
|
||||
HTS_INLINE int __rech_tageqbegdigits(const char *adr, const char *s);
|
||||
HTS_INLINE int rech_tageq_all(const char *adr, const char *s);
|
||||
|
||||
int hts_template_format(FILE *const out, const char *format, ...);
|
||||
int hts_template_format_str(char *buffer, size_t size, const char *format, ...);
|
||||
|
||||
#define rech_tageq(adr,s) \
|
||||
( \
|
||||
( (*((adr)-1)=='<') || (is_space(*((adr)-1))) ) ? \
|
||||
@@ -96,7 +84,7 @@ int hts_template_format_str(char *buffer, size_t size, const char *format, ...);
|
||||
//HTS_INLINE int rech_tageq(const char* adr,const char* s);
|
||||
HTS_INLINE int rech_sampletag(const char *adr, const char *s);
|
||||
HTS_INLINE int rech_endtoken(const char *adr, const char **start);
|
||||
HTS_INLINE int check_tag(const char *from, const char *tag);
|
||||
HTS_INLINE int check_tag(char *from, const char *tag);
|
||||
int verif_backblue(httrackp * opt, const char *base);
|
||||
int verif_external(httrackp * opt, int nb, int test);
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ static void back_launch_cmd(void *pP) {
|
||||
commandReturnCmdl = strdup(cmd);
|
||||
|
||||
/* split */
|
||||
argv[0] = strdup("webhttrack");
|
||||
argv[0] = "webhttrack";
|
||||
argv[1] = cmd;
|
||||
argc++;
|
||||
i = 0;
|
||||
@@ -264,7 +264,6 @@ static void back_launch_cmd(void *pP) {
|
||||
/* init */
|
||||
hts_init();
|
||||
global_opt = opt = hts_create_opt();
|
||||
assert(opt->size_httrackp == sizeof(httrackp));
|
||||
|
||||
/* run */
|
||||
commandReturn = webhttrack_runmain(opt, argc, argv);
|
||||
|
||||
118
src/htswizard.c
118
src/htswizard.c
@@ -42,6 +42,10 @@ Please visit our Website: http://www.httrack.com
|
||||
#include <ctype.h>
|
||||
/* END specific definitions */
|
||||
|
||||
// pour alléger la syntaxe, des raccourcis sont créés
|
||||
#define urladr (liens[ptr]->adr)
|
||||
#define urlfil (liens[ptr]->fil)
|
||||
|
||||
// libérer filters[0] pour insérer un élément dans filters[0]
|
||||
#define HT_INSERT_FILTERS0 do {\
|
||||
int i;\
|
||||
@@ -56,8 +60,8 @@ Please visit our Website: http://www.httrack.com
|
||||
} while(0)
|
||||
|
||||
typedef struct htspair_t {
|
||||
const char *tag;
|
||||
const char *attr;
|
||||
char *tag;
|
||||
char *attr;
|
||||
} htspair_t;
|
||||
|
||||
/* "embedded" */
|
||||
@@ -75,9 +79,9 @@ htspair_t hts_detect_embed[] = {
|
||||
};
|
||||
|
||||
/* Internal */
|
||||
static int hts_acceptlink_(httrackp * opt, int ptr, const char *adr,
|
||||
const char *fil, const char *tag,
|
||||
const char *attribute, int *set_prio_to,
|
||||
static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
|
||||
lien_url ** liens, char *adr, char *fil, char *tag,
|
||||
char *attribute, int *set_prio_to,
|
||||
int *just_test_it);
|
||||
|
||||
/*
|
||||
@@ -100,11 +104,10 @@ retour:
|
||||
-1 pas d'avis
|
||||
*/
|
||||
|
||||
int hts_acceptlink(httrackp * opt, int ptr,
|
||||
const char *adr, const char *fil,
|
||||
const char *tag, const char *attribute,
|
||||
int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens,
|
||||
char *adr, char *fil, char *tag, char *attribute,
|
||||
int *set_prio_to, int *just_test_it) {
|
||||
int forbidden_url = hts_acceptlink_(opt, ptr,
|
||||
int forbidden_url = hts_acceptlink_(opt, ptr, lien_tot, liens,
|
||||
adr, fil, tag, attribute, set_prio_to,
|
||||
just_test_it);
|
||||
int prev_prio = set_prio_to ? *set_prio_to : 0;
|
||||
@@ -130,9 +133,9 @@ static int cmp_token(const char *tag, const char *cmp) {
|
||||
&& !isalnum((unsigned char) tag[p]));
|
||||
}
|
||||
|
||||
static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
const char *adr, const char *fil, const char *tag,
|
||||
const char *attribute, int *set_prio_to,
|
||||
static int hts_acceptlink_(httrackp * opt, int ptr, int lien_tot,
|
||||
lien_url ** liens, char *adr, char *fil, char *tag,
|
||||
char *attribute, int *set_prio_to,
|
||||
int *just_test_it) {
|
||||
int forbidden_url = -1;
|
||||
int meme_adresse;
|
||||
@@ -184,8 +187,8 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
|
||||
/* Niveau 1: ne pas parser suivant! */
|
||||
if (ptr > 0) {
|
||||
if ((heap(ptr)->depth <= 0)
|
||||
|| (heap(ptr)->depth <= 1 && !embedded_triggered)) {
|
||||
if ((liens[ptr]->depth <= 0)
|
||||
|| (liens[ptr]->depth <= 1 && !embedded_triggered)) {
|
||||
forbidden_url = 1; // interdire récupération du lien
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"file from too far level ignored at %s : %s", adr, fil);
|
||||
@@ -200,11 +203,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
|
||||
// ------------------------------------------------------
|
||||
// doit-on traiter ce lien?.. vérifier droits de déplacement
|
||||
meme_adresse = strfield2(adr, urladr());
|
||||
meme_adresse = strfield2(adr, urladr);
|
||||
if (meme_adresse)
|
||||
hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr());
|
||||
hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s=%s", adr, urladr);
|
||||
else
|
||||
hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr());
|
||||
hts_log_print(opt, LOG_DEBUG, "Compare addresses: %s!=%s", adr, urladr);
|
||||
if (meme_adresse) { // même adresse
|
||||
{ // tester interdiction de descendre
|
||||
// MODIFIE : en cas de remontée puis de redescente, il se pouvait qu'on ne puisse pas atteindre certains fichiers
|
||||
@@ -217,15 +220,15 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
// note (up/down): on calcule à partir du lien primaire, ET du lien précédent.
|
||||
// ex: si on descend 2 fois on peut remonter 1 fois
|
||||
|
||||
if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) {
|
||||
if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) {
|
||||
if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) {
|
||||
if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"build relative links to test: %s %s (with %s and %s)",
|
||||
tempo, tempo2, heap(heap(ptr)->premier)->fil,
|
||||
heap(ptr)->fil);
|
||||
tempo, tempo2, liens[liens[ptr]->premier]->fil,
|
||||
liens[ptr]->fil);
|
||||
|
||||
// si vient de primary, ne pas tester lienrelatif avec (car host "différent")
|
||||
/*if (heap(heap(ptr)->premier) == 0) { // vient de primary
|
||||
/*if (liens[liens[ptr]->premier] == 0) { // vient de primary
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -239,7 +242,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
|| (tempo2[0] != '\0' && tempo2[1] != '\0'
|
||||
&& strchr(tempo2 + 1, '/') == 0)
|
||||
) {
|
||||
if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
|
||||
if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
|
||||
forbidden_url = 0;
|
||||
hts_log_print(opt, LOG_DEBUG, "same level link authorized: %s%s",
|
||||
adr, fil);
|
||||
@@ -264,7 +267,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
hts_log_print(opt, LOG_DEBUG, "lower link canceled: %s%s", adr,
|
||||
fil);
|
||||
} else { // autorisé à priori - NEW
|
||||
if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
|
||||
if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
|
||||
forbidden_url = 0;
|
||||
hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s",
|
||||
adr, fil);
|
||||
@@ -272,7 +275,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
}
|
||||
} else if ((test1) || (test2)) { // on peut descendre pour accéder au lien
|
||||
if ((opt->seeker & 1) != 0) { // on peut descendre - NEW
|
||||
if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
|
||||
if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
|
||||
forbidden_url = 0;
|
||||
hts_log_print(opt, LOG_DEBUG, "lower link authorized: %s%s",
|
||||
adr, fil);
|
||||
@@ -288,7 +291,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
hts_log_print(opt, LOG_DEBUG, "upper link canceled: %s%s", adr,
|
||||
fil);
|
||||
} else { // autorisé à monter - NEW
|
||||
if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
|
||||
if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
|
||||
forbidden_url = 0;
|
||||
hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s",
|
||||
adr, fil);
|
||||
@@ -296,7 +299,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
}
|
||||
} else if ((!strncmp(tempo, "../", 3)) || (!strncmp(tempo2, "../", 3))) { // Possible en montant
|
||||
if ((opt->seeker & 2) != 0) { // autorisé à monter - NEW
|
||||
if (!heap(ptr)->link_import) { // ne résulte pas d'un 'moved'
|
||||
if (!liens[ptr]->link_import) { // ne résulte pas d'un 'moved'
|
||||
forbidden_url = 0;
|
||||
hts_log_print(opt, LOG_DEBUG, "upper link authorized: %s%s",
|
||||
adr, fil);
|
||||
@@ -307,11 +310,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR,
|
||||
"Error building relative link %s and %s", fil,
|
||||
heap(ptr)->fil);
|
||||
liens[ptr]->fil);
|
||||
}
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s",
|
||||
fil, heap(heap(ptr)->premier)->fil);
|
||||
fil, liens[liens[ptr]->premier]->fil);
|
||||
}
|
||||
|
||||
} // tester interdiction de descendre?
|
||||
@@ -320,16 +323,16 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
char BIGSTK tempo[HTS_URLMAXSIZE * 2];
|
||||
char BIGSTK tempo2[HTS_URLMAXSIZE * 2];
|
||||
|
||||
if (lienrelatif(tempo, fil, heap(heap(ptr)->premier)->fil) == 0) {
|
||||
if (lienrelatif(tempo2, fil, heap(ptr)->fil) == 0) {
|
||||
if (lienrelatif(tempo, fil, liens[liens[ptr]->premier]->fil) == 0) {
|
||||
if (lienrelatif(tempo2, fil, liens[ptr]->fil) == 0) {
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR,
|
||||
"Error building relative link %s and %s", fil,
|
||||
heap(ptr)->fil);
|
||||
liens[ptr]->fil);
|
||||
}
|
||||
} else {
|
||||
hts_log_print(opt, LOG_ERROR, "Error building relative link %s and %s",
|
||||
fil, heap(heap(ptr)->premier)->fil);
|
||||
fil, liens[liens[ptr]->premier]->fil);
|
||||
|
||||
}
|
||||
} // fin tester interdiction de monter
|
||||
@@ -345,24 +348,24 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
break; // interdicton de sortir au dela de l'adresse
|
||||
case 1:{ // sortie sur le même dom.xxx
|
||||
size_t i = strlen(adr) - 1;
|
||||
size_t j = strlen(urladr()) - 1;
|
||||
size_t j = strlen(urladr) - 1;
|
||||
|
||||
if ((i > 0) && (j > 0)) {
|
||||
while((i > 0) && (adr[i] != '.'))
|
||||
i--;
|
||||
while((j > 0) && (urladr()[j] != '.'))
|
||||
while((j > 0) && (urladr[j] != '.'))
|
||||
j--;
|
||||
if ((i > 0) && (j > 0)) {
|
||||
i--;
|
||||
j--;
|
||||
while((i > 0) && (adr[i] != '.'))
|
||||
i--;
|
||||
while((j > 0) && (urladr()[j] != '.'))
|
||||
while((j > 0) && (urladr[j] != '.'))
|
||||
j--;
|
||||
}
|
||||
}
|
||||
if ((i > 0) && (j > 0)) {
|
||||
if (!strfield2(adr + i, urladr() + j)) { // !=
|
||||
if (!strfield2(adr + i, urladr + j)) { // !=
|
||||
if (!opt->wizard) { // mode non wizard
|
||||
//printf("refused: %s\n",adr);
|
||||
forbidden_url = 1; // pas même domaine
|
||||
@@ -384,14 +387,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
break;
|
||||
case 2:{ // sortie sur le même .xxx
|
||||
size_t i = strlen(adr) - 1;
|
||||
size_t j = strlen(urladr()) - 1;
|
||||
size_t j = strlen(urladr) - 1;
|
||||
|
||||
while((i > 0) && (adr[i] != '.'))
|
||||
i--;
|
||||
while((j > 0) && (urladr()[j] != '.'))
|
||||
while((j > 0) && (urladr[j] != '.'))
|
||||
j--;
|
||||
if ((i > 0) && (j > 0)) {
|
||||
if (!strfield2(adr + i, urladr() + j)) { // !-
|
||||
if (!strfield2(adr + i, urladr + j)) { // !-
|
||||
if (!opt->wizard) { // mode non wizard
|
||||
//printf("refused: %s\n",adr);
|
||||
forbidden_url = 1; // pas même .xx
|
||||
@@ -490,7 +493,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
// there is no way yet to tag "external" links, and therefore links that are
|
||||
// "weak" (authorized depth < external depth) are just not considered for external
|
||||
// hack
|
||||
if (heap(ptr)->depth > opt->extdepth) {
|
||||
if (liens[ptr]->depth > opt->extdepth) {
|
||||
// *set_prio_to = opt->extdepth + 1;
|
||||
*set_prio_to = 1 + (opt->extdepth);
|
||||
may_set_prio_to = 0; // clear may-set flag
|
||||
@@ -499,11 +502,11 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
if (question) {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) ambiguous link accepted (external depth): link %s at %s%s",
|
||||
l, urladr(), urlfil());
|
||||
l, urladr, urlfil);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) forced to accept link (external depth): link %s at %s%s",
|
||||
l, urladr(), urlfil());
|
||||
l, urladr, urlfil);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -512,7 +515,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
// filters
|
||||
{
|
||||
int jok;
|
||||
const char *mdepth = "";
|
||||
char *mdepth = "";
|
||||
|
||||
// filters, 0=sait pas 1=ok -1=interdit
|
||||
{
|
||||
@@ -547,14 +550,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
may_set_prio_to = 0; // clear may-set flag
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) explicit authorized (%s) link: link %s at %s%s",
|
||||
mdepth, l, urladr(), urlfil());
|
||||
mdepth, l, urladr, urlfil);
|
||||
} else if (jok == -1) { // forbidden
|
||||
filters_answer = 1; // décision prise par les filtres
|
||||
question = 0; // ne pas poser de question:
|
||||
forbidden_url = 1; // URL interdite
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) explicit forbidden (%s) link: link %s at %s%s",
|
||||
mdepth, l, urladr(), urlfil());
|
||||
mdepth, l, urladr, urlfil);
|
||||
} // sinon on touche à rien
|
||||
}
|
||||
}
|
||||
@@ -562,14 +565,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
// vérifier mode mirror links
|
||||
if (question) {
|
||||
if (opt->mirror_first_page) { // mode mirror links
|
||||
if (heap(ptr)->precedent == 0) { // parent=primary!
|
||||
if (liens[ptr]->precedent == 0) { // parent=primary!
|
||||
forbidden_url = 0; // autorisé
|
||||
may_set_prio_to = 0; // clear may-set flag
|
||||
question = 1; // résolution auto
|
||||
force_mirror = 5; // mirror (5)
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) explicit mirror link: link %s at %s%s", l,
|
||||
urladr(), urlfil());
|
||||
urladr, urlfil);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,7 +584,7 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
forbidden_url = 1;
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) ambiguous forbidden link: link %s at %s%s", l,
|
||||
urladr(), urlfil());
|
||||
urladr, urlfil);
|
||||
}
|
||||
}
|
||||
// vérifier robots.txt
|
||||
@@ -616,14 +619,14 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
if (!forbidden_url) {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) shared foreign domain link: link %s at %s%s", l,
|
||||
urladr(), urlfil());
|
||||
urladr, urlfil);
|
||||
} else {
|
||||
hts_log_print(opt, LOG_DEBUG,
|
||||
"(wizard) cancelled foreign domain link: link %s at %s%s",
|
||||
l, urladr(), urlfil());
|
||||
l, urladr, urlfil);
|
||||
}
|
||||
#if BDEBUG==3
|
||||
printf("at %s in %s, wizard says: url %s ", urladr(), urlfil(), l);
|
||||
printf("at %s in %s, wizard says: url %s ", urladr, urlfil, l);
|
||||
if (forbidden_url)
|
||||
printf("cancelled");
|
||||
else
|
||||
@@ -860,13 +863,13 @@ static int hts_acceptlink_(httrackp * opt, int ptr,
|
||||
#undef _ROBOTS
|
||||
}
|
||||
|
||||
int hts_acceptmime(httrackp * opt, int ptr,
|
||||
const char *adr, const char *fil, const char *mime) {
|
||||
int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens,
|
||||
char *adr, char *fil, char *mime) {
|
||||
#define _FILTERS (*opt->filters.filters)
|
||||
#define _FILTERS_PTR (opt->filters.filptr)
|
||||
#define _ROBOTS ((robots_wizard*)opt->robotsptr)
|
||||
int forbidden_url = -1;
|
||||
const char *mdepth = "";
|
||||
char *mdepth = "";
|
||||
int jokDepth = 0;
|
||||
int jok = 0;
|
||||
|
||||
@@ -903,7 +906,7 @@ int hts_acceptmime(httrackp * opt, int ptr,
|
||||
}
|
||||
|
||||
// tester taille
|
||||
int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size) {
|
||||
int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size) {
|
||||
int jok = 0;
|
||||
|
||||
if (size >= 0) {
|
||||
@@ -981,4 +984,7 @@ int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint siz
|
||||
return jok;
|
||||
}
|
||||
|
||||
#undef urladr
|
||||
#undef urlfil
|
||||
|
||||
#undef HT_INSERT_FILTERS0
|
||||
|
||||
@@ -49,13 +49,12 @@ typedef struct httrackp httrackp;
|
||||
typedef struct lien_url lien_url;
|
||||
#endif
|
||||
|
||||
int hts_acceptlink(httrackp * opt, int ptr,
|
||||
const char *adr, const char *fil,
|
||||
const char *tag, const char *attribute,
|
||||
int hts_acceptlink(httrackp * opt, int ptr, int lien_tot, lien_url ** liens,
|
||||
char *adr, char *fil, char *tag, char *attribute,
|
||||
int *set_prio_to_0, int *just_test_it);
|
||||
int hts_testlinksize(httrackp * opt, const char *adr, const char *fil, LLint size);
|
||||
int hts_acceptmime(httrackp * opt, int ptr,
|
||||
const char *adr, const char *fil, const char *mime);
|
||||
int hts_testlinksize(httrackp * opt, char *adr, char *fil, LLint size);
|
||||
int hts_acceptmime(httrackp * opt, int ptr, int lien_tot, lien_url ** liens,
|
||||
char *adr, char *fil, char *mime);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -198,7 +198,7 @@ HTSEXT_API char *jump_normalized(const char *);
|
||||
HTSEXT_API char *jump_toport(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);
|
||||
HTSEXT_API char *hts_rootdir(char *file);
|
||||
|
||||
/* Escaping URLs */
|
||||
HTSEXT_API void unescape_amp(char *s);
|
||||
@@ -239,9 +239,7 @@ HTSEXT_API void get_httptype(httrackp * opt, char *s, const char *fil,
|
||||
HTSEXT_API int is_knowntype(httrackp * opt, const char *fil);
|
||||
HTSEXT_API int is_userknowntype(httrackp * opt, const char *fil);
|
||||
HTSEXT_API int is_dyntype(const char *fil);
|
||||
HTSEXT_API const char *get_ext(char *catbuff, size_t size, const char *fil);
|
||||
HTSEXT_API int may_unknown(httrackp * opt, const char *st);
|
||||
HTSEXT_API void guess_httptype(httrackp * opt, char *s, const char *fil);
|
||||
HTSEXT_API char *get_ext(char *catbuff, size_t size, const char *fil);
|
||||
|
||||
/* Ugly string tools */
|
||||
HTSEXT_API char *concat(char *catbuff, size_t size, const char *a, const char *b);
|
||||
|
||||
@@ -224,7 +224,6 @@ int main(int argc, char **argv) {
|
||||
signal_handlers();
|
||||
hts_init();
|
||||
opt = global_opt = hts_create_opt();
|
||||
assert(opt->size_httrackp == sizeof(httrackp));
|
||||
|
||||
CHAIN_FUNCTION(opt, init, htsshow_init, NULL);
|
||||
CHAIN_FUNCTION(opt, uninit, htsshow_uninit, NULL);
|
||||
|
||||
29
src/md5.c
29
src/md5.c
@@ -88,7 +88,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) {
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t) {
|
||||
unsigned char *p = ctx->in.ui8 + t;
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
|
||||
t = 64 - t;
|
||||
if (len < t) {
|
||||
@@ -97,25 +97,25 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) {
|
||||
}
|
||||
memcpy(p, buf, t);
|
||||
if (ctx->doByteReverse)
|
||||
byteReverse(ctx->in.ui8, 16);
|
||||
MD5Transform(ctx->buf, ctx->in.ui32);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while(len >= 64) {
|
||||
memcpy(ctx->in.ui8, buf, 64);
|
||||
memcpy(ctx->in, buf, 64);
|
||||
if (ctx->doByteReverse)
|
||||
byteReverse(ctx->in.ui8, 16);
|
||||
MD5Transform(ctx->buf, ctx->in.ui32);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in.ui8, buf, len);
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -131,7 +131,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) {
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in.ui8 + count;
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
@@ -142,27 +142,26 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) {
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset(p, 0, count);
|
||||
if (ctx->doByteReverse)
|
||||
byteReverse(ctx->in.ui8, 16);
|
||||
MD5Transform(ctx->buf, ctx->in.ui32);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset(ctx->in.ui8, 0, 56);
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
/* Pad block to 56 bytes */
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
if (ctx->doByteReverse)
|
||||
byteReverse(ctx->in.ui8, 14);
|
||||
byteReverse(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
/* Note: see patch for PAM from Tomas Mraz */
|
||||
ctx->in.ui32[14] = ctx->bits[0];
|
||||
ctx->in.ui32[15] = ctx->bits[1];
|
||||
memcpy((uint32 *) ctx->in + 14, ctx->bits, 2 * sizeof(uint32));
|
||||
/*((uint32 *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32 *) ctx->in)[15] = ctx->bits[1];
|
||||
*/
|
||||
|
||||
MD5Transform(ctx->buf, ctx->in.ui32);
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
if (ctx->doByteReverse)
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
|
||||
@@ -18,10 +18,7 @@ typedef unsigned long uint32;
|
||||
#endif
|
||||
|
||||
struct MD5Context {
|
||||
union {
|
||||
unsigned char ui8[64];
|
||||
uint32 ui32[16];
|
||||
} in;
|
||||
unsigned char in[64];
|
||||
uint32 buf[4];
|
||||
uint32 bits[2];
|
||||
int doByteReverse;
|
||||
|
||||
55
src/minizip/ChangeLogUnzip
Executable file
55
src/minizip/ChangeLogUnzip
Executable file
@@ -0,0 +1,55 @@
|
||||
Change in 1.00: (10 sept 03)
|
||||
- rename to 1.00
|
||||
- cosmetic code change
|
||||
|
||||
Change in 0.22: (19 May 03)
|
||||
- crypting support (unless you define NOCRYPT)
|
||||
- append file in existing zipfile
|
||||
|
||||
Change in 0.21: (10 Mar 03)
|
||||
- bug fixes
|
||||
|
||||
Change in 0.17: (27 Jan 02)
|
||||
- bug fixes
|
||||
|
||||
Change in 0.16: (19 Jan 02)
|
||||
- Support of ioapi for virtualize zip file access
|
||||
|
||||
Change in 0.15: (19 Mar 98)
|
||||
- fix memory leak in minizip.c
|
||||
|
||||
Change in 0.14: (10 Mar 98)
|
||||
- fix bugs in minizip.c sample for zipping big file
|
||||
- fix problem in month in date handling
|
||||
- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for
|
||||
comment handling
|
||||
|
||||
Change in 0.13: (6 Mar 98)
|
||||
- fix bugs in zip.c
|
||||
- add real minizip sample
|
||||
|
||||
Change in 0.12: (4 Mar 98)
|
||||
- add zip.c and zip.h for creates .zip file
|
||||
- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
|
||||
- fix miniunz.c for file without specific record for directory
|
||||
|
||||
Change in 0.11: (3 Mar 98)
|
||||
- fix bug in unzGetCurrentFileInfo for get extra field and comment
|
||||
- enhance miniunz sample, remove the bad unztst.c sample
|
||||
|
||||
Change in 0.10: (2 Mar 98)
|
||||
- fix bug in unzReadCurrentFile
|
||||
- rename unzip* to unz* function and structure
|
||||
- remove Windows-like hungary notation variable name
|
||||
- modify some structure in unzip.h
|
||||
- add somes comment in source
|
||||
- remove unzipGetcCurrentFile function
|
||||
- replace ZUNZEXPORT by ZEXPORT
|
||||
- add unzGetLocalExtrafield for get the local extrafield info
|
||||
- add a new sample, miniunz.c
|
||||
|
||||
Change in 0.4: (25 Feb 98)
|
||||
- suppress the type unzipFileInZip.
|
||||
Only on file in the zipfile can be open at the same time
|
||||
- fix somes typo in code
|
||||
- added tm_unz structure in unzip_file_info (date/time in readable format)
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
MiniZip 1.1 was derrived from MiniZip at version 1.01f
|
||||
|
||||
Change in 1.0 (Okt 2009)
|
||||
- **TODO - Add history**
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
|
||||
|
||||
Introduction
|
||||
---------------------
|
||||
MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
|
||||
When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
|
||||
All possible work was done for compatibility.
|
||||
|
||||
|
||||
Background
|
||||
---------------------
|
||||
When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64
|
||||
support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
|
||||
|
||||
That was used as a starting point. And after that ZIP64 support was added to zip.c
|
||||
some refactoring and code cleanup was also done.
|
||||
|
||||
|
||||
Changed from MiniZip 1.0 to MiniZip 1.1
|
||||
---------------------------------------
|
||||
* Added ZIP64 support for unzip ( by Even Rouault )
|
||||
* Added ZIP64 support for zip ( by Mathias Svensson )
|
||||
* Reverted some changed that Even Rouault did.
|
||||
* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
|
||||
* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
|
||||
* Added BZIP Compress method for zip
|
||||
* Did some refactoring and code cleanup
|
||||
|
||||
|
||||
Credits
|
||||
|
||||
Gilles Vollant - Original MiniZip author
|
||||
Even Rouault - ZIP64 unzip Support
|
||||
Daniel Borca - BZip Compression method support in unzip
|
||||
Mathias Svensson - ZIP64 zip support
|
||||
Mathias Svensson - BZip Compression method support in zip
|
||||
|
||||
Resources
|
||||
|
||||
ZipLayout http://result42.com/projects/ZipFileLayout
|
||||
Command line tool for Windows that shows the layout and information of the headers in a zip archive.
|
||||
Used when debugging and validating the creation of zip files using MiniZip64
|
||||
|
||||
|
||||
ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT
|
||||
Zip File specification
|
||||
|
||||
|
||||
Notes.
|
||||
* To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
|
||||
|
||||
License
|
||||
----------------------------------------------------------
|
||||
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.
|
||||
|
||||
----------------------------------------------------------
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.01e, February 12th, 2005
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2005 Gilles Vollant
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
/***********************************************************************
|
||||
* Return the next byte in the pseudo-random sequence
|
||||
*/
|
||||
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||
* unpredictable manner on 16-bit systems; not a problem
|
||||
@@ -45,7 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||
/***********************************************************************
|
||||
* Update the encryption keys with the next byte of plain text
|
||||
*/
|
||||
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
||||
{
|
||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||
@@ -62,7 +62,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||
* Initialize the encryption keys and the random header according to
|
||||
* the given password.
|
||||
*/
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
|
||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
||||
{
|
||||
*(pkeys+0) = 305419896L;
|
||||
*(pkeys+1) = 591751049L;
|
||||
@@ -87,12 +87,13 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcr
|
||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||
# endif
|
||||
|
||||
static int crypthead(const char* passwd, /* password string */
|
||||
unsigned char* buf, /* where to write header */
|
||||
int bufSize,
|
||||
unsigned long* pkeys,
|
||||
const z_crc_t* pcrc_32_tab,
|
||||
unsigned long crcForCrypting)
|
||||
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||
const char *passwd; /* password string */
|
||||
unsigned char *buf; /* where to write header */
|
||||
int bufSize;
|
||||
unsigned long* pkeys;
|
||||
const unsigned long* pcrc_32_tab;
|
||||
unsigned long crcForCrypting;
|
||||
{
|
||||
int n; /* index in random header */
|
||||
int t; /* temporary */
|
||||
@@ -123,8 +124,8 @@ static int crypthead(const char* passwd, /* password string */
|
||||
{
|
||||
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
|
||||
}
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
|
||||
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,101 +1,83 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
/* ioapi.c -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
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
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#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)
|
||||
#ifndef _WIN32_WCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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)
|
||||
#include <stdio.h>
|
||||
//#include "celib.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "zlib.h"
|
||||
#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.zflush_file = p_filefunc32->zflush_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;
|
||||
}
|
||||
|
||||
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
||||
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 fflush_file_func OF((voidpf opaque, voidpf stream));
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
#endif
|
||||
|
||||
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2
|
||||
#endif
|
||||
|
||||
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func OF((
|
||||
voidpf opaque,
|
||||
const char* filename,
|
||||
int mode));
|
||||
|
||||
uLong ZCALLBACK fread_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
void* buf,
|
||||
uLong size));
|
||||
|
||||
uLong ZCALLBACK fwrite_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
const void* buf,
|
||||
uLong size));
|
||||
|
||||
long ZCALLBACK ftell_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
long ZCALLBACK fseek_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
uLong offset,
|
||||
int origin));
|
||||
|
||||
int ZCALLBACK fflush_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
int ZCALLBACK fclose_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
int ZCALLBACK ferror_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
|
||||
voidpf opaque;
|
||||
const char* filename;
|
||||
int mode;
|
||||
{
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
@@ -113,55 +95,44 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
||||
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 ZCALLBACK fread_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||
ret = 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 ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
const void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
|
||||
long ZCALLBACK ftell_file_func (opaque, stream)
|
||||
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)
|
||||
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
uLong offset;
|
||||
int origin;
|
||||
{
|
||||
int fseek_origin=0;
|
||||
long ret;
|
||||
@@ -179,51 +150,31 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
|
||||
default: return -1;
|
||||
}
|
||||
ret = 0;
|
||||
if (fseek((FILE *)stream, offset, fseek_origin) != 0)
|
||||
ret = -1;
|
||||
fseek((FILE *)stream, offset, fseek_origin);
|
||||
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 fflush_file_func (voidpf opaque, voidpf stream)
|
||||
int ZCALLBACK fflush_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
ret = fflush((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||
int ZCALLBACK fclose_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
ret = fclose((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
|
||||
int ZCALLBACK ferror_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
ret = ferror((FILE *)stream);
|
||||
@@ -243,16 +194,3 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||
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->zflush_file = fflush_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
--- ioapi.c.orig 2012-01-21 20:58:45.000000000 +0100
|
||||
+++ ioapi.c 2014-05-24 13:27:22.516230485 +0200
|
||||
@@ -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;
|
||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||
+ p_filefunc64_32->zfile_func64.zflush_file = p_filefunc32->zflush_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;
|
||||
@@ -89,6 +90,8 @@
|
||||
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 fflush_file_func OF((voidpf opaque, voidpf stream));
|
||||
+
|
||||
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
|
||||
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
|
||||
|
||||
@@ -206,6 +209,12 @@
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int ZCALLBACK fflush_file_func (voidpf opaque, voidpf stream)
|
||||
+{
|
||||
+ int ret;
|
||||
+ ret = fflush((FILE *)stream);
|
||||
+ return ret;
|
||||
+}
|
||||
|
||||
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
@@ -229,6 +238,7 @@
|
||||
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->zflush_file = fflush_file_func;
|
||||
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 @@
|
||||
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->zflush_file = fflush_file_func;
|
||||
pzlib_filefunc_def->zclose_file = fclose_file_func;
|
||||
pzlib_filefunc_def->zerror_file = ferror_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
177
src/minizip/ioapi.c.orig
Normal file
177
src/minizip/ioapi.c.orig
Normal file
@@ -0,0 +1,177 @@
|
||||
/* ioapi.c -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
|
||||
|
||||
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func OF((
|
||||
voidpf opaque,
|
||||
const char* filename,
|
||||
int mode));
|
||||
|
||||
uLong ZCALLBACK fread_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
void* buf,
|
||||
uLong size));
|
||||
|
||||
uLong ZCALLBACK fwrite_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
const void* buf,
|
||||
uLong size));
|
||||
|
||||
long ZCALLBACK ftell_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
long ZCALLBACK fseek_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
uLong offset,
|
||||
int origin));
|
||||
|
||||
int ZCALLBACK fclose_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
int ZCALLBACK ferror_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
|
||||
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
ret = fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
const void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret;
|
||||
ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK ftell_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
long ret;
|
||||
ret = ftell((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
|
||||
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;
|
||||
fseek((FILE *)stream, offset, fseek_origin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK fclose_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret;
|
||||
ret = fclose((FILE *)stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK ferror_file_func (opaque, stream)
|
||||
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;
|
||||
}
|
||||
@@ -1,112 +1,13 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
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)
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#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
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#define ZLIB_FILEFUNC_SEEK_CUR (1)
|
||||
@@ -122,91 +23,61 @@ extern "C" {
|
||||
|
||||
|
||||
#ifndef ZCALLBACK
|
||||
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
|
||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* fixed missing define on some zlib (Lars Wendler) */
|
||||
#ifndef OF
|
||||
#define OF(args) args
|
||||
#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 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));
|
||||
typedef int (ZCALLBACK *flush_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
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 *flush_file_func) OF((voidpf opaque, voidpf stream));
|
||||
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;
|
||||
flush_file_func zflush_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
flush_file_func zflush_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;
|
||||
flush_file_func zflush_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 ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZFLUSH(filefunc,filestream) ((*((filefunc).zflush_file))((filefunc).opaque,filestream))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#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 ZFLUSH64(filefunc,filestream) ((*((filefunc).zfile_func64.zflush_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
//#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
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
--- 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 @@
|
||||
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 *flush_file_func) OF((voidpf opaque, voidpf stream));
|
||||
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 @@
|
||||
open_file_func zopen_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
+ flush_file_func zflush_file;
|
||||
tell_file_func ztell_file;
|
||||
seek_file_func zseek_file;
|
||||
close_file_func zclose_file;
|
||||
@@ -164,6 +166,7 @@
|
||||
open64_file_func zopen64_file;
|
||||
read_file_func zread_file;
|
||||
write_file_func zwrite_file;
|
||||
+ flush_file_func zflush_file;
|
||||
tell64_file_func ztell64_file;
|
||||
seek64_file_func zseek64_file;
|
||||
close_file_func zclose_file;
|
||||
@@ -186,6 +189,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))
|
||||
+#define ZFLUSH64(filefunc,filestream) ((*((filefunc).zfile_func64.zflush_file)) ((filefunc).zfile_func64.opaque,filestream))
|
||||
//#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))
|
||||
75
src/minizip/ioapi.h.orig
Normal file
75
src/minizip/ioapi.h.orig
Normal file
@@ -0,0 +1,75 @@
|
||||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#define _ZLIBIOAPI_H
|
||||
|
||||
|
||||
#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 (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
|
||||
#define ZCALLBACK CALLBACK
|
||||
#else
|
||||
#define ZCALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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 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));
|
||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
|
||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
|
||||
|
||||
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;
|
||||
|
||||
|
||||
|
||||
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
|
||||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
|
||||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
|
||||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
|
||||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
|
||||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/* iowin32.c -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
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
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32_WCE
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
//#include "celib.h"
|
||||
#endif
|
||||
|
||||
#include "zlib.h"
|
||||
#include "ioapi.h"
|
||||
@@ -25,20 +26,40 @@
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func OF((
|
||||
voidpf opaque,
|
||||
const char* filename,
|
||||
int mode));
|
||||
|
||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define IOWIN32_USING_WINRT_API 1
|
||||
#endif
|
||||
#endif
|
||||
uLong ZCALLBACK win32_read_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
void* buf,
|
||||
uLong size));
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
|
||||
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
|
||||
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
|
||||
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
|
||||
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
|
||||
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
|
||||
uLong ZCALLBACK win32_write_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
const void* buf,
|
||||
uLong size));
|
||||
|
||||
long ZCALLBACK win32_tell_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
long ZCALLBACK win32_seek_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream,
|
||||
uLong offset,
|
||||
int origin));
|
||||
|
||||
int ZCALLBACK win32_close_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
int ZCALLBACK win32_error_file_func OF((
|
||||
voidpf opaque,
|
||||
voidpf stream));
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -46,163 +67,69 @@ typedef struct
|
||||
int error;
|
||||
} WIN32FILE_IOWIN;
|
||||
|
||||
|
||||
static void win32_translate_open_mode(int mode,
|
||||
DWORD* lpdwDesiredAccess,
|
||||
DWORD* lpdwCreationDisposition,
|
||||
DWORD* lpdwShareMode,
|
||||
DWORD* lpdwFlagsAndAttributes)
|
||||
voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode)
|
||||
voidpf opaque;
|
||||
const char* filename;
|
||||
int mode;
|
||||
{
|
||||
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = 0;
|
||||
voidpf ret=NULL;
|
||||
|
||||
dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0;
|
||||
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_READ;
|
||||
*lpdwCreationDisposition = OPEN_EXISTING;
|
||||
*lpdwShareMode = FILE_SHARE_READ;
|
||||
dwDesiredAccess = GENERIC_READ;
|
||||
dwCreationDisposition = OPEN_EXISTING;
|
||||
dwShareMode = FILE_SHARE_READ;
|
||||
}
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
*lpdwCreationDisposition = OPEN_EXISTING;
|
||||
dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
dwCreationDisposition = OPEN_EXISTING;
|
||||
}
|
||||
else if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
{
|
||||
*lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
*lpdwCreationDisposition = CREATE_ALWAYS;
|
||||
dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
|
||||
dwCreationDisposition = CREATE_ALWAYS;
|
||||
}
|
||||
}
|
||||
|
||||
static voidpf win32_build_iowin(HANDLE hFile)
|
||||
{
|
||||
voidpf ret=NULL;
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL,
|
||||
dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
|
||||
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
hFile = NULL;
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
WIN32FILE_IOWIN w32fiow;
|
||||
w32fiow.hf = hFile;
|
||||
w32fiow.error = 0;
|
||||
ret = malloc(sizeof(WIN32FILE_IOWIN));
|
||||
|
||||
if (ret==NULL)
|
||||
CloseHandle(hFile);
|
||||
else
|
||||
*((WIN32FILE_IOWIN*)ret) = w32fiow;
|
||||
else *((WIN32FILE_IOWIN*)ret) = w32fiow;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
#ifdef UNICODE
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode)
|
||||
{
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode)
|
||||
{
|
||||
const char* mode_fopen = NULL;
|
||||
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
|
||||
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
#ifdef UNICODE
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
{
|
||||
WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
|
||||
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
|
||||
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
if ((filename!=NULL) && (dwDesiredAccess != 0))
|
||||
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
|
||||
#endif
|
||||
|
||||
return win32_build_iowin(hFile);
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size)
|
||||
uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
if (!ReadFile(hFile, buf, size, &ret, NULL))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
@@ -210,21 +137,23 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL
|
||||
dwErr = 0;
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size)
|
||||
uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
const void* buf;
|
||||
uLong size;
|
||||
{
|
||||
uLong ret=0;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
if (hFile !=NULL)
|
||||
if (!WriteFile(hFile, buf, size, &ret, NULL))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
@@ -232,32 +161,13 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b
|
||||
dwErr = 0;
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
|
||||
{
|
||||
#ifdef IOWIN32_USING_WINRT_API
|
||||
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
|
||||
#else
|
||||
LONG lHigh = pos.HighPart;
|
||||
DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT);
|
||||
BOOL fOk = TRUE;
|
||||
if (dwNewPos == 0xFFFFFFFF)
|
||||
if (GetLastError() != NO_ERROR)
|
||||
fOk = FALSE;
|
||||
if ((newPos != NULL) && (fOk))
|
||||
{
|
||||
newPos->LowPart = dwNewPos;
|
||||
newPos->HighPart = lHigh;
|
||||
}
|
||||
return fOk;
|
||||
#endif
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
||||
long ZCALLBACK win32_tell_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
long ret=-1;
|
||||
HANDLE hFile = NULL;
|
||||
@@ -265,47 +175,24 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
|
||||
if (hFile != NULL)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = 0;
|
||||
|
||||
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
||||
DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
|
||||
if (dwSet == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
ret=(long)pos.LowPart;
|
||||
ret=(long)dwSet;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
|
||||
{
|
||||
ZPOS64_T ret= (ZPOS64_T)-1;
|
||||
HANDLE hFile = NULL;
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
||||
|
||||
if (hFile)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = 0;
|
||||
|
||||
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = (ZPOS64_T)-1;
|
||||
}
|
||||
else
|
||||
ret=pos.QuadPart;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
|
||||
long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
uLong offset;
|
||||
int origin;
|
||||
{
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
@@ -329,9 +216,8 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
|
||||
|
||||
if (hFile != NULL)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = offset;
|
||||
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
|
||||
DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
|
||||
if (dwSet == INVALID_SET_FILE_POINTER)
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
@@ -343,46 +229,9 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
|
||||
return ret;
|
||||
}
|
||||
|
||||
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin)
|
||||
{
|
||||
DWORD dwMoveMethod=0xFFFFFFFF;
|
||||
HANDLE hFile = NULL;
|
||||
long ret=-1;
|
||||
|
||||
if (stream!=NULL)
|
||||
hFile = ((WIN32FILE_IOWIN*)stream)->hf;
|
||||
|
||||
switch (origin)
|
||||
{
|
||||
case ZLIB_FILEFUNC_SEEK_CUR :
|
||||
dwMoveMethod = FILE_CURRENT;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_END :
|
||||
dwMoveMethod = FILE_END;
|
||||
break;
|
||||
case ZLIB_FILEFUNC_SEEK_SET :
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
|
||||
if (hFile)
|
||||
{
|
||||
LARGE_INTEGER pos;
|
||||
pos.QuadPart = offset;
|
||||
if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT))
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
|
||||
ret = -1;
|
||||
}
|
||||
else
|
||||
ret=0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
||||
int ZCALLBACK win32_close_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret=-1;
|
||||
|
||||
@@ -400,7 +249,9 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
||||
int ZCALLBACK win32_error_file_func (opaque, stream)
|
||||
voidpf opaque;
|
||||
voidpf stream;
|
||||
{
|
||||
int ret=-1;
|
||||
if (stream!=NULL)
|
||||
@@ -410,7 +261,8 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
void fill_win32_filefunc (pzlib_filefunc_def)
|
||||
zlib_filefunc_def* pzlib_filefunc_def;
|
||||
{
|
||||
pzlib_filefunc_def->zopen_file = win32_open_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
@@ -419,43 +271,5 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
|
||||
pzlib_filefunc_def->zseek_file = win32_seek_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
}
|
||||
|
||||
|
||||
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def)
|
||||
{
|
||||
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
|
||||
pzlib_filefunc_def->zread_file = win32_read_file_func;
|
||||
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
|
||||
pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
|
||||
pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
|
||||
pzlib_filefunc_def->zclose_file = win32_close_file_func;
|
||||
pzlib_filefunc_def->zerror_file = win32_error_file_func;
|
||||
pzlib_filefunc_def->opaque = NULL;
|
||||
pzlib_filefunc_def->opaque=NULL;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
/* iowin32.h -- IO base function header for compress/uncompress .zip
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
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
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
@@ -19,9 +15,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,289 +1,287 @@
|
||||
/*
|
||||
Additional tools for Minizip
|
||||
Code: Xavier Roche '2004
|
||||
License: Same as ZLIB (www.gzip.org)
|
||||
*/
|
||||
|
||||
/* Code */
|
||||
/*
|
||||
Additional tools for Minizip
|
||||
Code: Xavier Roche '2004
|
||||
License: Same as ZLIB (www.gzip.org)
|
||||
*/
|
||||
|
||||
/* Code */
|
||||
#include <string.h>
|
||||
#ifndef _WIN32_WCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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) )
|
||||
#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)
|
||||
|
||||
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");
|
||||
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];
|
||||
const char* comment = "";
|
||||
const size_t comsize = 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 (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];
|
||||
const char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
|
||||
const size_t comsize = 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 (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;
|
||||
}
|
||||
#include <stdlib.h>
|
||||
#include "celib.h"
|
||||
#endif
|
||||
#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) && 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_STREAM_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Extra field */
|
||||
if (extsize > 0) {
|
||||
if (extsize < sizeof(extra) && 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = 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;
|
||||
}
|
||||
|
||||
@@ -17,21 +17,15 @@ extern "C" {
|
||||
|
||||
#include "unzip.h"
|
||||
|
||||
/* Repair a ZIP file (missing central directory)
|
||||
/* Repair a ZIP file (missing central directory)
|
||||
file: file to recover
|
||||
fileOut: output file after recovery
|
||||
fileOutTmp: temporary file name used for recovery
|
||||
*/
|
||||
extern int ZEXPORT unzRepair(const char* file,
|
||||
const char* fileOut,
|
||||
const char* fileOutTmp,
|
||||
extern int ZEXPORT unzRepair(const char* file,
|
||||
const char* fileOut,
|
||||
const char* fileOutTmp,
|
||||
uLong* nRecovered,
|
||||
uLong* bytesRecovered);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
1364
src/minizip/unzip.c
1364
src/minizip/unzip.c
File diff suppressed because it is too large
Load Diff
1585
src/minizip/unzip.c.orig
Normal file
1585
src/minizip/unzip.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,18 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.1, February 14h, 2010
|
||||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
Modifications of Unzip for Zip64
|
||||
Copyright (C) 2007-2008 Even Rouault
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
Modifications for Zip64 support on both zip and unzip
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
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
|
||||
@@ -32,16 +30,18 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
|
||||
Changes
|
||||
|
||||
See header of unzip64.c
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _unz64_H
|
||||
#define _unz64_H
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -51,16 +51,10 @@ extern "C" {
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BZIP2
|
||||
#include "bzlib.h"
|
||||
#endif
|
||||
|
||||
#define Z_BZIP2ED 12
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
@@ -93,42 +87,15 @@ typedef struct tm_unz_s
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info64_s
|
||||
{
|
||||
ZPOS64_T number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info64;
|
||||
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info64_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
ZPOS64_T compressed_size; /* compressed size 8 bytes */
|
||||
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info64;
|
||||
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
@@ -164,7 +131,6 @@ extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
@@ -173,14 +139,8 @@ extern unzFile ZEXPORT unzOpen64 OF((const void *path));
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
the "64" function take a const void* pointer, because the path is just the
|
||||
value passed to the open64_file_func callback.
|
||||
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
|
||||
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
|
||||
does not describe the reality
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
@@ -188,25 +148,15 @@ extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unz64Open, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzOpen.
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzCloseCurrentFile before call unzClose.
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
|
||||
unz_global_info64 *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
@@ -269,31 +219,8 @@ extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
typedef struct unz64_file_pos_s
|
||||
{
|
||||
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */
|
||||
ZPOS64_T num_of_file; /* # of file */
|
||||
} unz64_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos64(
|
||||
unzFile file,
|
||||
unz64_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos64(
|
||||
unzFile file,
|
||||
const unz64_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
|
||||
unz_file_info64 *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
@@ -315,14 +242,6 @@ extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
|
||||
/** Addition for GDAL : START */
|
||||
|
||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
|
||||
|
||||
/** Addition for GDAL : END */
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
@@ -391,8 +310,6 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
|
||||
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
@@ -421,11 +338,9 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
@@ -434,4 +349,4 @@ extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz64_H */
|
||||
#endif /* _unz_H */
|
||||
|
||||
352
src/minizip/unzip.h.orig
Normal file
352
src/minizip/unzip.h.orig
Normal file
@@ -0,0 +1,352 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_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_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
|
||||
"zlib/zlib113.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
|
||||
zlib_filefunc_def* pzlib_filefunc_def));
|
||||
/*
|
||||
Open a Zip file, like unzOpen, but provide a set of file low level API
|
||||
for read/write the zip file (see ioapi.h)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
/* ****************************************** */
|
||||
/* Ryan supplied functions */
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_pos_s
|
||||
{
|
||||
uLong pos_in_zip_directory; /* offset in zip file directory */
|
||||
uLong num_of_file; /* # of file */
|
||||
} unz_file_pos;
|
||||
|
||||
extern int ZEXPORT unzGetFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
extern int ZEXPORT unzGoToFilePos(
|
||||
unzFile file,
|
||||
unz_file_pos* file_pos);
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
|
||||
const char* password));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
password is a crypting password
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
|
||||
int* method,
|
||||
int* level,
|
||||
int raw,
|
||||
const char* password));
|
||||
/*
|
||||
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
|
||||
if raw==1
|
||||
*method will receive method of compression, *level will receive level of
|
||||
compression
|
||||
note : you can set level parameter as NULL (if you did not want known level,
|
||||
but you CANNOT set method parameter as NULL
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
||||
1899
src/minizip/zip.c
1899
src/minizip/zip.c
File diff suppressed because it is too large
Load Diff
@@ -1,85 +0,0 @@
|
||||
--- zip.c.orig 2013-02-24 08:32:30.000000000 +0100
|
||||
+++ zip.c 2014-05-24 13:52:45.570151611 +0200
|
||||
@@ -186,7 +186,7 @@
|
||||
#include "crypt.h"
|
||||
#endif
|
||||
|
||||
-local linkedlist_datablock_internal* allocate_new_datablock()
|
||||
+local linkedlist_datablock_internal* allocate_new_datablock(void)
|
||||
{
|
||||
linkedlist_datablock_internal* ldi;
|
||||
ldi = (linkedlist_datablock_internal*)
|
||||
@@ -637,7 +637,7 @@
|
||||
return relativeOffset;
|
||||
}
|
||||
|
||||
-int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
+local int LoadCentralDirectoryRecord(zip64_internal* pziinit)
|
||||
{
|
||||
int err=ZIP_OK;
|
||||
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
|
||||
@@ -955,7 +955,7 @@
|
||||
return zipOpen3(pathname,append,NULL,NULL);
|
||||
}
|
||||
|
||||
-int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
||||
+local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local)
|
||||
{
|
||||
/* write the local header */
|
||||
int err;
|
||||
@@ -1752,7 +1752,7 @@
|
||||
return zipCloseFileInZipRaw (file,0,0);
|
||||
}
|
||||
|
||||
-int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
||||
+local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip)
|
||||
{
|
||||
int err = ZIP_OK;
|
||||
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset;
|
||||
@@ -1774,7 +1774,7 @@
|
||||
return err;
|
||||
}
|
||||
|
||||
-int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
+local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
{
|
||||
int err = ZIP_OK;
|
||||
|
||||
@@ -1813,7 +1813,8 @@
|
||||
}
|
||||
return err;
|
||||
}
|
||||
-int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
+
|
||||
+local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
|
||||
{
|
||||
int err = ZIP_OK;
|
||||
|
||||
@@ -1861,7 +1862,7 @@
|
||||
return err;
|
||||
}
|
||||
|
||||
-int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||
+local int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
|
||||
{
|
||||
int err = ZIP_OK;
|
||||
uInt size_global_comment = 0;
|
||||
@@ -1879,6 +1880,18 @@
|
||||
return err;
|
||||
}
|
||||
|
||||
+extern int ZEXPORT zipFlush (zipFile file)
|
||||
+{
|
||||
+ zip64_internal* zi;
|
||||
+
|
||||
+ if (file == NULL)
|
||||
+ return ZIP_PARAMERROR;
|
||||
+
|
||||
+ zi = (zip64_internal*)file;
|
||||
+
|
||||
+ return ZFLUSH64(zi->z_filefunc,zi->filestream);
|
||||
+}
|
||||
+
|
||||
extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
|
||||
{
|
||||
zip64_internal* zi;
|
||||
1180
src/minizip/zip.c.orig
Normal file
1180
src/minizip/zip.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,18 @@
|
||||
/* 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 )
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
Modifications for Zip64 support
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
@@ -29,23 +32,23 @@
|
||||
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
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define HAVE_BZIP2
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
@@ -54,12 +57,6 @@ extern "C" {
|
||||
#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 */
|
||||
@@ -114,7 +111,6 @@ typedef const char* zipcharpc;
|
||||
#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
|
||||
@@ -139,16 +135,6 @@ extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
|
||||
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 zipFile ZEXPORT zipOpen3 OF((const void *pathname,
|
||||
int append,
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_32_def* pzlib_filefunc64_32_def));
|
||||
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
@@ -159,19 +145,6 @@ extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
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
|
||||
@@ -183,9 +156,6 @@ extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -201,19 +171,6 @@ extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
|
||||
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
|
||||
*/
|
||||
@@ -233,79 +190,13 @@ extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
|
||||
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
|
||||
));
|
||||
uLong crcForCtypting));
|
||||
|
||||
/*
|
||||
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)
|
||||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
|
||||
@@ -316,11 +207,6 @@ extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipFlush OF((zipFile file));
|
||||
/*
|
||||
Flush the zipfile output
|
||||
*/
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
@@ -329,13 +215,8 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
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
|
||||
Close the current file in the zipfile, for fiel opened with
|
||||
parameter raw=1 in zipOpenNewFileInZip2
|
||||
uncompressed_size and crc32 are value for the uncompressed size
|
||||
*/
|
||||
@@ -346,27 +227,13 @@ extern int ZEXPORT zipClose OF((zipFile file,
|
||||
Close the zipfile
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
|
||||
extern int ZEXPORT zipFlush OF((zipFile file));
|
||||
/*
|
||||
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);
|
||||
Flush the zipfile output
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip64_H */
|
||||
#endif /* _zip_H */
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
--- zip.h.orig 2010-02-15 12:58:22.000000000 +0100
|
||||
+++ zip.h 2014-05-24 13:47:52.838188589 +0200
|
||||
@@ -144,6 +144,11 @@
|
||||
zipcharpc* globalcomment,
|
||||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
|
||||
+extern zipFile ZEXPORT zipOpen3 OF((const void *pathname,
|
||||
+ int append,
|
||||
+ zipcharpc* globalcomment,
|
||||
+ zlib_filefunc64_32_def* pzlib_filefunc64_32_def));
|
||||
+
|
||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
|
||||
const char* filename,
|
||||
const zip_fileinfo* zipfi,
|
||||
@@ -311,6 +316,11 @@
|
||||
Write data in the zipfile
|
||||
*/
|
||||
|
||||
+extern int ZEXPORT zipFlush OF((zipFile file));
|
||||
+/*
|
||||
+ Flush the zipfile output
|
||||
+*/
|
||||
+
|
||||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
||||
/*
|
||||
Close the current file in the zipfile
|
||||
235
src/minizip/zip.h.orig
Normal file
235
src/minizip/zip.h.orig
Normal file
@@ -0,0 +1,235 @@
|
||||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
For uncompress .zip file, look at unzip.h
|
||||
|
||||
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
|
||||
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
|
||||
http://www.info-zip.org/pub/infozip/doc/
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip
|
||||
*/
|
||||
|
||||
#ifndef _zip_H
|
||||
#define _zip_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
#include "ioapi.h"
|
||||
#endif
|
||||
|
||||
#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));
|
||||
/*
|
||||
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 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));
|
||||
/*
|
||||
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)
|
||||
*/
|
||||
|
||||
|
||||
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));
|
||||
|
||||
/*
|
||||
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 crcForCtypting));
|
||||
|
||||
/*
|
||||
Same than zipOpenNewFileInZip2, except
|
||||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
|
||||
password : crypting password (NULL for no crypting)
|
||||
crcForCtypting : crc of file to compress (needed for crypting)
|
||||
*/
|
||||
|
||||
|
||||
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));
|
||||
/*
|
||||
Close the current file in the zipfile, for fiel 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
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _zip_H */
|
||||
@@ -31,7 +31,6 @@ Please visit our Website: http://www.httrack.com
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define HTSSAFE_ABORT_FUNCTION(A,B,C)
|
||||
#include "htsbase.h"
|
||||
#include "htsnet.h"
|
||||
#include "htslib.h"
|
||||
|
||||
@@ -109,8 +109,8 @@ HTS_UNUSED static void proxytrack_print_log(const char *severity, const char *fo
|
||||
"<!-- _-._.--._._-._.--._._-._.--._._-._.--._._-._.--._. -->\r\n" \
|
||||
"<!-- End Disable IE Friendly HTTP Error Messages -->\r\n"
|
||||
|
||||
HTS_UNUSED static const char *gethomedir(void) {
|
||||
const char *home = getenv("HOME");
|
||||
HTS_UNUSED static char *gethomedir(void) {
|
||||
char *home = getenv("HOME");
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
@@ -216,7 +216,7 @@ HTS_UNUSED static const char *jump_protocol_and_auth(const char *source) {
|
||||
#endif
|
||||
HTS_UNUSED static int linput_trim(FILE * fp, char *s, int max) {
|
||||
int rlen = 0;
|
||||
char *const ls = (char *) malloc(max + 1);
|
||||
char *ls = (char *) malloc(max + 2);
|
||||
|
||||
s[0] = '\0';
|
||||
if (ls) {
|
||||
|
||||
@@ -1253,7 +1253,7 @@ static int PT_SaveCache__New_Fun(void *arg, const char *url, PT_Element element)
|
||||
headersSize = 0;
|
||||
/* */
|
||||
{
|
||||
const char *message;
|
||||
char *message;
|
||||
|
||||
if (strlen(element->msg) < 32) {
|
||||
message = element->msg;
|
||||
|
||||
@@ -104,7 +104,6 @@ DATA = $(templates_DATA)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -113,12 +112,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -132,7 +133,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -188,6 +188,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
@@ -98,4 +98,4 @@ h4 { margin: 0; font-weight: bold; font-size: 1.18em; }
|
||||
|
||||
|
||||
<h1 ALIGN=Center>Index of locally available projects:</H1>
|
||||
<table border="0" width="100%%" cellspacing="1" cellpadding="0">
|
||||
<table border="0" width="100%%%" cellspacing="1" cellpadding="0">
|
||||
|
||||
@@ -76,7 +76,6 @@ red=; grn=; lgn=; blu=; std=
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_CFLAGS = @AM_CFLAGS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
@@ -85,12 +84,14 @@ AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_CFLAGS = @DEFAULT_CFLAGS@
|
||||
DEFAULT_LDFLAGS = @DEFAULT_LDFLAGS@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
@@ -104,7 +105,6 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_VISIBILITY = @HAVE_VISIBILITY@
|
||||
HTTPS_SUPPORT = @HTTPS_SUPPORT@
|
||||
ICONV_LIBS = @ICONV_LIBS@
|
||||
INSTALL = @INSTALL@
|
||||
@@ -160,6 +160,7 @@ abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
|
||||
Reference in New Issue
Block a user