Added hydra zlib compression

This commit is contained in:
Michiel Broek 2003-10-13 13:20:48 +00:00
parent a619282f8a
commit 091633fae3
5 changed files with 182 additions and 32 deletions

View File

@ -3,8 +3,7 @@ $Id$
WARNING: This code contains unfinished changes, if you use the bbs WARNING: This code contains unfinished changes, if you use the bbs
then do not use this version. then do not use this version.
This code also contains changes in the hydra code, this This code also contains changes in the hydra code, this
should be safe to use because the code is disabled for is under test.
endusers.
v0.39.0 09-Oct-2003 v0.39.0 09-Oct-2003
@ -26,8 +25,10 @@ v0.39.0 09-Oct-2003
used password for the menu (Was only present in the setup). used password for the menu (Was only present in the setup).
mbcico: mbcico:
Started adding code for zlib compression of hydra packets. Added Hydra zlib compressed data blocks using the idea of Alex
Not functional yet and disabled by configure. Shakhaylo. This is experimental and looks compatible with
mailers that don't support this option. The compression will
transfer some files about twice as fast as without compression.
lang: lang:
Added language prompt 20. Added language prompt 20.

2
TODO
View File

@ -123,8 +123,6 @@ mbcico:
U: Fix binkp file resume when mbcico silently dies. U: Fix binkp file resume when mbcico silently dies.
N: Add zlib compression to Hydra (Alex Shakhaylo).
mbfile: mbfile:
L: Add a check to see if the magic filenames are (still) valid. L: Add a check to see if the magic filenames are (still) valid.

142
configure vendored
View File

@ -4324,6 +4324,148 @@ fi
if test "$result" = "yes"; then if test "$result" = "yes"; then
LIBS="$LIBS -lz" LIBS="$LIBS -lz"
for ac_header in zlib.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
no:yes )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
fi fi
echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo "$as_me:$LINENO: checking for ANSI C header files" >&5

View File

@ -126,7 +126,7 @@ fi
AC_CHECK_LIB(z,compress,result=yes,result=no) AC_CHECK_LIB(z,compress,result=yes,result=no)
if test "$result" = "yes"; then if test "$result" = "yes"; then
LIBS="$LIBS -lz" LIBS="$LIBS -lz"
dnl AC_CHECK_HEADERS(zlib.h) AC_CHECK_HEADERS(zlib.h)
fi fi
dnl Checks for header files. dnl Checks for header files.

View File

@ -999,7 +999,6 @@ int hydra_batch(int role, file_list *to_send)
fseek(txfp, txpos, SEEK_SET); fseek(txfp, txpos, SEEK_SET);
put_long(txbuf, txpos); put_long(txbuf, txpos);
Nopper(); Nopper();
Syslog('h', "Check for more frames here?");
txlen = fread(txbuf + 4, 1, blksize, txfp); txlen = fread(txbuf + 4, 1, blksize, txfp);
Syslog('h', "Hydra: send DATA (0x%08lx) %lu", txpos, txlen); Syslog('h', "Hydra: send DATA (0x%08lx) %lu", txpos, txlen);
@ -1011,15 +1010,15 @@ int hydra_batch(int role, file_list *to_send)
txstate = HTX_EOF; txstate = HTX_EOF;
} }
} else { } else {
// FIXME: Here we must add the compression code
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
if (txoptions & HOPT_CANPLZ) { if ((txoptions & HOPT_CANPLZ) && (txretries == 0)) {
txzlen = H_ZIPBUFLEN; txzlen = H_ZIPBUFLEN - 4;
rcz = compress(txzbuf, &txzlen, txbuf, txlen); rcz = compress(txzbuf + 4, &txzlen, txbuf + 4, txlen);
if (rcz == Z_OK) { if (rcz == Z_OK) {
Syslog('h', "Compressed OK, srclen=%d, destlen=%d, will send compressed=%s", txlen, txzlen, Syslog('h', "Compressed OK, srclen=%d, destlen=%d, will send compressed=%s", txlen, txzlen,
(txzlen < txlen) ?"yes":"no"); (txzlen < txlen) ?"yes":"no");
if (txzlen < txlen) { if (txzlen < txlen) {
put_long(txzbuf, txpos);
txpos += txlen; txpos += txlen;
sentbytes += txlen; sentbytes += txlen;
goodbytes += txlen; goodbytes += txlen;
@ -1043,6 +1042,15 @@ int hydra_batch(int role, file_list *to_send)
txlen += 4; txlen += 4;
hytxpkt(HPKT_DATA, txbuf, txlen); hytxpkt(HPKT_DATA, txbuf, txlen);
} }
} else {
/*
* Remote doesn't support PLZ, use standard hydra method.
*/
txpos += txlen;
sentbytes += txlen;
goodbytes += txlen;
txlen += 4;
hytxpkt(HPKT_DATA, txbuf, txlen);
} }
#else #else
txpos += txlen; txpos += txlen;
@ -1364,9 +1372,7 @@ int hydra_batch(int role, file_list *to_send)
Name = dosname; Name = dosname;
} }
Syslog('+', "Hydra: receive \"%s\" (%ld bytes) dated %s", Syslog('+', "Hydra: receive \"%s\" (%ld bytes) dated %s", Name, filesize, date(timestamp));
Name, filesize, date(timestamp));
rxfp = openfile(Name, timestamp, filesize, &rxpos, resync); rxfp = openfile(Name, timestamp, filesize, &rxpos, resync);
gettimeofday(&rxstarttime, &tz); gettimeofday(&rxstarttime, &tz);
@ -1421,6 +1427,25 @@ int hydra_batch(int role, file_list *to_send)
Syslog('h', "SM 'HRX' entering 'DATA'"); Syslog('h', "SM 'HRX' entering 'DATA'");
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
if (((pkttype == HPKT_DATA) || (pkttype == HPKT_ZIPDATA)) && (rxlen > 4)) { if (((pkttype == HPKT_DATA) || (pkttype == HPKT_ZIPDATA)) && (rxlen > 4)) {
/*
* If data packet is a zlib compressed packet, uncompress it first.
*/
if (pkttype == HPKT_ZIPDATA) {
rxzlen = H_ZIPBUFLEN;
rcz = uncompress(rxzbuf, &rxzlen, rxbuf + 4, rxlen - 4);
if (rcz == Z_OK) {
/*
* Uncompress data and put the data into the normal receive buffer.
*/
Syslog('h', "uncompressed size %d => %d", rxlen -4, rxzlen);
memcpy(rxbuf + 4, rxzbuf, rxzlen);
rxlen = rxzlen + 4;
} else {
Syslog('+', "Hydra: ZIPDATA uncompress error, sending BadPos");
rxstate = HRX_BadPos;
pkttype = H_NOPKT; /* packet has already been processed */
}
}
longnum = get_long(rxbuf); longnum = get_long(rxbuf);
Syslog('h', "Hydra: rcvd %sDATA (0x%08lx, 0x%08lx) %lu", (pkttype == HPKT_ZIPDATA) ? "ZIP":"", Syslog('h', "Hydra: rcvd %sDATA (0x%08lx, 0x%08lx) %lu", (pkttype == HPKT_ZIPDATA) ? "ZIP":"",
longnum, rxpos, rxlen-4); longnum, rxpos, rxlen-4);
@ -1430,24 +1455,8 @@ int hydra_batch(int role, file_list *to_send)
Syslog('h', "Hydra: rcvd DATA (0x%08lx, 0x%08lx) %lu", longnum, rxpos, rxlen-4); Syslog('h', "Hydra: rcvd DATA (0x%08lx, 0x%08lx) %lu", longnum, rxpos, rxlen-4);
#endif #endif
Nopper(); Nopper();
Syslog('h', "longnum=%d, rxpos=%d", longnum, rxpos);
if (longnum == rxpos) { if (longnum == rxpos) {
#ifdef HAVE_ZLIB_H
if (pkttype == HPKT_ZIPDATA) {
rxzlen = H_ZIPBUFLEN;
rcz = uncompress(rxzbuf, &rxzlen, rxbuf + 4, rxlen - 4);
if (rcz == Z_OK) {
/*
* Uncompress data and put the data into the normal
* receive buffer.
*/
Syslog('h', "uncompressed size %d => %d", rxlen -4, rxzlen);
memcpy(rxbuf + 4, rxzbuf, rxzlen);
rxlen = rxzlen + 4;
} else {
Syslog('h', "Uncompress error, fatal what should we do");
}
}
#endif
if (fwrite(rxbuf + 4, 1, rxlen - 4, rxfp) != (rxlen - 4)) { if (fwrite(rxbuf + 4, 1, rxlen - 4, rxfp) != (rxlen - 4)) {
WriteError("$Hydra: error writing to file"); WriteError("$Hydra: error writing to file");
rxpos = -2; rxpos = -2;