diff --git a/ChangeLog b/ChangeLog index e42a3c32..cbc5e722 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,7 @@ $Id$ WARNING: This code contains unfinished changes, if you use the bbs then do not use this version. This code also contains changes in the hydra code, this - should be safe to use because the code is disabled for - endusers. + is under test. 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). mbcico: - Started adding code for zlib compression of hydra packets. - Not functional yet and disabled by configure. + Added Hydra zlib compressed data blocks using the idea of Alex + 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: Added language prompt 20. diff --git a/TODO b/TODO index 8894ced8..71b4b585 100644 --- a/TODO +++ b/TODO @@ -123,8 +123,6 @@ mbcico: U: Fix binkp file resume when mbcico silently dies. - N: Add zlib compression to Hydra (Alex Shakhaylo). - mbfile: L: Add a check to see if the magic filenames are (still) valid. diff --git a/configure b/configure index 51604072..45b89c6d 100755 --- a/configure +++ b/configure @@ -4324,7 +4324,149 @@ fi if test "$result" = "yes"; then 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 echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 diff --git a/configure.in b/configure.in index 8189042c..7349fc98 100644 --- a/configure.in +++ b/configure.in @@ -126,7 +126,7 @@ fi AC_CHECK_LIB(z,compress,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lz" - dnl AC_CHECK_HEADERS(zlib.h) + AC_CHECK_HEADERS(zlib.h) fi dnl Checks for header files. diff --git a/mbcico/hydra.c b/mbcico/hydra.c index 506fb3fb..a9277545 100644 --- a/mbcico/hydra.c +++ b/mbcico/hydra.c @@ -999,7 +999,6 @@ int hydra_batch(int role, file_list *to_send) fseek(txfp, txpos, SEEK_SET); put_long(txbuf, txpos); Nopper(); - Syslog('h', "Check for more frames here?"); txlen = fread(txbuf + 4, 1, blksize, txfp); 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; } } else { - // FIXME: Here we must add the compression code #ifdef HAVE_ZLIB_H - if (txoptions & HOPT_CANPLZ) { - txzlen = H_ZIPBUFLEN; - rcz = compress(txzbuf, &txzlen, txbuf, txlen); + if ((txoptions & HOPT_CANPLZ) && (txretries == 0)) { + txzlen = H_ZIPBUFLEN - 4; + rcz = compress(txzbuf + 4, &txzlen, txbuf + 4, txlen); if (rcz == Z_OK) { Syslog('h', "Compressed OK, srclen=%d, destlen=%d, will send compressed=%s", txlen, txzlen, (txzlen < txlen) ?"yes":"no"); if (txzlen < txlen) { + put_long(txzbuf, txpos); txpos += txlen; sentbytes += txlen; goodbytes += txlen; @@ -1043,6 +1042,15 @@ int hydra_batch(int role, file_list *to_send) txlen += 4; 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 txpos += txlen; @@ -1364,9 +1372,7 @@ int hydra_batch(int role, file_list *to_send) Name = dosname; } - Syslog('+', "Hydra: receive \"%s\" (%ld bytes) dated %s", - Name, filesize, date(timestamp)); - + Syslog('+', "Hydra: receive \"%s\" (%ld bytes) dated %s", Name, filesize, date(timestamp)); rxfp = openfile(Name, timestamp, filesize, &rxpos, resync); gettimeofday(&rxstarttime, &tz); @@ -1421,6 +1427,25 @@ int hydra_batch(int role, file_list *to_send) Syslog('h', "SM 'HRX' entering 'DATA'"); #ifdef HAVE_ZLIB_H 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); Syslog('h', "Hydra: rcvd %sDATA (0x%08lx, 0x%08lx) %lu", (pkttype == HPKT_ZIPDATA) ? "ZIP":"", 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); #endif Nopper(); + Syslog('h', "longnum=%d, rxpos=%d", 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)) { WriteError("$Hydra: error writing to file"); rxpos = -2;