Home | History | Annotate | Download | only in ftp
History log of /src/usr.bin/ftp/progressbar.c
RevisionDateAuthorComments
 1.27  04-Oct-2024  christos use unsigned when doing shifts.
 1.26  25-Sep-2024  christos pass some lint.
 1.25  19-Jul-2024  lukem ftp: improve units used in comments and errors

Use "KiB" instead of "K" in errors.
Clarify related comments.
 1.24  06-Jan-2021  lukem branches: 1.24.6; 1.24.8;
ftp: don't use restartable signals

Refactor to not rely upon restartable signals (SA_RESTART),
possibly fixing intermittent failures with -q QUITTIME.

ftp transfers: handle EINTR/EAGAIN in copy_bytes(),
instead of relying upon restartable signals.

http/https transfers: Explicitly print an error similar to
progressmeter() when timing-out for -Q QUITTIME in fetch_wait(),
and set errno to ETIMEDOUT so that the warn() in fetch_url()
prints a more accurate error message.

PR/55857
 1.23  22-Jun-2019  christos branches: 1.23.2;
make this compile again with -DNO_PROGRESS
 1.22  27-Jun-2012  riastradh branches: 1.22.24; 1.22.32;
Clean up #includes in progress(1).

Sort them, omit needless ones, and add omitted needful ones.

Omissions revealed by pilfering the code and trying to build it on
Mac OS X. We ought to have a better way to reveal these omissions...
 1.21  12-Apr-2009  lukem branches: 1.21.6; 1.21.8;
Fix numerous WARNS=4 issues (-Wcast-qual -Wsign-compare).
 1.20  30-Sep-2008  lukem branches: 1.20.6;
update copyrights
 1.19  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.18  21-Jan-2008  lukem branches: 1.18.4;
Turn off the alarmtimer before resetting the SIGALRM handler back to SIG_DFL.
Fix from dieter roelants <dieter.NetBSD@pandora.be>
Should fix PR 35630.
 1.17  05-May-2007  martin branches: 1.17.4;
const-as-const-can: make the "suffixes" pointers const, as probably was
intended, but done wrong originally (redundant const was removed
per PR bin/36280)
 1.16  05-May-2007  christos PR/36280: Christer Folkesson: Remove extra const
 1.15  17-Apr-2007  lukem * Implement -s srcaddr; uses srcaddr as the local IP address for all
connections.
Based on code in the version of ftp that FreeBSD had before they
replaced it with lukemftp.
* Move error message handling into ftp_connect() rather than in the
caller, so that more specific error reporting can occur.
* Improve consistency of various warning and error messages.
 1.14  12-Apr-2007  lukem Use the IEC 60027-2 2^n based "KiB", "MiB", "GiB", (etc)
suffixes for byte displays since we're using 2^n scaling,
instead of the SI 10^n based "KB", "MB", "GB" (etc).
 1.13  01-May-2006  christos Coverity CID 1447: Avoid buffer overflow.
 1.12  01-May-2006  christos Coverity CID 1448: Avoid static array overflow.
 1.11  19-Jul-2005  lukem Revert back to using an int (instead of size_t) for holding a value that may
be negative.
Fixes progressbar display on terminals <43 columns wide.
Bug noted and solution suggested by Gavan Fantom.
 1.10  09-Jun-2005  lukem copyright maintenance
 1.9  20-May-2005  he Printf field widths and size_t don't always mix well, so cast to int.
Fixes build problem for alpha.
 1.8  19-May-2005  lukem Use size_t instead of int where appropriate.
 1.7  11-Apr-2005  lukem gratuitous whitespace cleanup (before someone else jumps the gun...)
 1.6  10-Feb-2005  jmc branches: 1.6.2;
Fix compilation issues for NO_PROGRESS
 1.5  09-Mar-2004  hubertf Allow custom text printed before (left of) the progress bar from progress(1):

miyu# cat openoffice-linux-1.1.0.tgz | progress -z -p 'Bytes written: ' dd of=/dev/null bs=1m
Bytes written: 193 MB 13.83 MB/s 0+195211 records in
and:
miyu# progress -f openoffice-linux-1.1.0.tgz -z -p 'Bytes written: ' dd of=/dev/null bs=1m
Bytes written: 28% |****** | 57919 KB 14.12 MB/s 00:09 ETA

OK'd by lukem.
 1.4  17-Jul-2003  lukem tweak copyright; the stuff jason did in util.c wasn't migrated to this file.
 1.3  28-Feb-2003  lukem Crank dates on TNF copyright.
Remove UCB & WIDE copyrights; the progressbar functionality was
written entirely by me under the TNF copyright.
 1.2  12-Feb-2003  grant change a couple #ifdef's so /usr/bin/progress doesn't stomp all over
the tty if it's not in the foreground.

ok'd by jhawk.
 1.1  21-Jan-2003  jhawk branches: 1.1.2;
Abstract out progress bar support into progressbar.[ch], for inclusion
in external programs (conditionalized on -DSTANDALONE_PROGRESS).

The following moved from util.c to progressbar.c:
alarmtimer(), progressmeter(), psummary(), ptransfer(),
xsignal(), xsignal_restart()

The following moved from extern.h and ftp_var.h to progressbar.h:
STALLTIME, verbose, fromatty, progress, quit_time, ttywidth
 1.1.2.2  21-Jan-2003  jhawk Abstract out progress bar support into progressbar.[ch], for inclusion
in external programs (conditionalized on -DSTANDALONE_PROGRESS).

The following moved from util.c to progressbar.c:
alarmtimer(), progressmeter(), psummary(), ptransfer(),
xsignal(), xsignal_restart()

The following moved from extern.h and ftp_var.h to progressbar.h:
STALLTIME, verbose, fromatty, progress, quit_time, ttywidth
 1.1.2.1  21-Jan-2003  jhawk file progressbar.c was added on branch netbsd-1-6 on 2003-01-21 16:08:09 +0000
 1.6.2.5  24-Jul-2005  tron Pull up revision 1.11 (requested by lukem in ticket #606):
Revert back to using an int (instead of size_t) for holding a value that may
be negative.
Fixes progressbar display on terminals <43 columns wide.
Bug noted and solution suggested by Gavan Fantom.
 1.6.2.4  24-Jul-2005  tron Pull up revision 1.10 (requested by lukem in ticket #606):
copyright maintenance
 1.6.2.3  24-Jul-2005  tron Pull up revision 1.9 (requested by lukem in ticket #606):
Printf field widths and size_t don't always mix well, so cast to int.
Fixes build problem for alpha.
 1.6.2.2  24-Jul-2005  tron Pull up revision 1.8 (requested by lukem in ticket #606):
Use size_t instead of int where appropriate.
 1.6.2.1  09-May-2005  tron Pull up revision 1.7 (requested by lukem in ticket #266):
gratuitous whitespace cleanup (before someone else jumps the gun...)
 1.17.4.1  23-Mar-2008  matt sync with HEAD
 1.18.4.1  18-May-2008  yamt sync with head.
 1.20.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.21.8.1  17-Dec-2013  bouyer Apply patch, requested by tron in ticket #997:
usr.bin/ftp/Makefile patch
usr.bin/ftp/cmds.c patch
usr.bin/ftp/cmdtab.c patch
usr.bin/ftp/extern.h patch
usr.bin/ftp/fetch.c patch
usr.bin/ftp/ftp.1 patch
usr.bin/ftp/ftp.c patch
usr.bin/ftp/ftp_var.h patch
usr.bin/ftp/main.c patch
usr.bin/ftp/progressbar.c patch
usr.bin/ftp/ssl.c patch
usr.bin/ftp/ssl.h patch
usr.bin/ftp/util.c patch
usr.bin/ftp/version.h patch

Add HTTPS support to ftp(1).
 1.21.6.1  30-Oct-2012  yamt sync with head
 1.22.32.1  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.22.24.3  12-Sep-2022  martin Catch up to current, requested by christos in ticket #1763:

usr.bin/ftp/Makefile up to 1.39
usr.bin/ftp/cmds.c up to 1.141
usr.bin/ftp/complete.c up to 1.47
usr.bin/ftp/domacro.c up to 1.23
usr.bin/ftp/extern.h up to 1.82
usr.bin/ftp/fetch.c up to 1.235
usr.bin/ftp/ftp.1 up to 1.147
usr.bin/ftp/ftp.c up to 1.174
usr.bin/ftp/ftp_var.h up to 1.86
usr.bin/ftp/main.c up to 1.128
usr.bin/ftp/progressbar.c up to 1.24
usr.bin/ftp/progressbar.h up to 1.9
usr.bin/ftp/ssl.c up to 1.12
usr.bin/ftp/ssl.h up to 1.5
usr.bin/ftp/util.c up to 1.164
usr.bin/ftp/version.h up to 1.94

ftp(1): validate address from PASV and LPSV response.
ftp(1): use raw write(2) instead of fwrite(3) to avoid stream
corruption because of the progress bar interrupts.
Fixes for PR 56219 and PR 55857.
PR 57003: Support relative redirects.
 1.22.24.2  12-Sep-2022  martin Backout ticket #1763 for now - trust anchors are not solved.
 1.22.24.1  12-Sep-2022  martin Catch up to current, requested by christos in ticket #1763:

usr.bin/ftp/Makefile up to 1.39
usr.bin/ftp/cmds.c up to 1.141
usr.bin/ftp/complete.c up to 1.47
usr.bin/ftp/domacro.c up to 1.23
usr.bin/ftp/extern.h up to 1.82
usr.bin/ftp/fetch.c up to 1.235
usr.bin/ftp/ftp.1 up to 1.147
usr.bin/ftp/ftp.c up to 1.174
usr.bin/ftp/ftp_var.h up to 1.86
usr.bin/ftp/main.c up to 1.128
usr.bin/ftp/progressbar.c up to 1.24
usr.bin/ftp/progressbar.h up to 1.9
usr.bin/ftp/ssl.c up to 1.11
usr.bin/ftp/ssl.h up to 1.5
usr.bin/ftp/util.c up to 1.164
usr.bin/ftp/version.h up to 1.94

ftp(1): validate address from PASV and LPSV response.
ftp(1): use raw write(2) instead of fwrite(3) to avoid stream
corruption because of the progress bar interrupts.
Fixes for PR 56219 and PR 55857.
PR 57003: Support relative redirects.
 1.23.2.2  12-Sep-2022  martin Catch up to current, requested by christos in ticket #1523

usr.bin/ftp/Makefile up to 1.39
usr.bin/ftp/fetch.c up to 1.235
usr.bin/ftp/ftp.1 up to 1.147
usr.bin/ftp/ftp_var.h up to 1.86
usr.bin/ftp/main.c up to 1.128
usr.bin/ftp/ssl.c up to 1.12
usr.bin/ftp/util.c up to 1.164
usr.bin/ftp/version.h up to 1.94

PR 57003: Support relative redirects.
 1.23.2.1  29-Jan-2021  martin Pull up following revision(s) (requested by lukem in ticket #1190):

usr.bin/ftp/progressbar.c: revision 1.24
usr.bin/ftp/ssl.c: revision 1.9
usr.bin/ftp/progressbar.h: revision 1.9
usr.bin/ftp/ftp.c: revision 1.171
usr.bin/ftp/version.h: revision 1.92

ftp: don't use restartable signals

Refactor to not rely upon restartable signals (SA_RESTART),
possibly fixing intermittent failures with -q QUITTIME.
ftp transfers: handle EINTR/EAGAIN in copy_bytes(),
instead of relying upon restartable signals.

http/https transfers: Explicitly print an error similar to
progressmeter() when timing-out for -Q QUITTIME in fetch_wait(),
and set errno to ETIMEDOUT so that the warn() in fetch_url()
prints a more accurate error message.

PR/55857
 1.24.8.1  02-Aug-2025  perseant Sync with HEAD
 1.24.6.2  02-Dec-2024  martin Pull up following revision(s) (requested by lukem in ticket #1021):

usr.bin/ftp/ftp.c: revision 1.178
usr.bin/ftp/version.h: revision 1.99
usr.bin/ftp/ruserpass.c: revision 1.35
usr.bin/ftp/main.c: revision 1.134
usr.bin/ftp/main.c: revision 1.135
usr.bin/ftp/progressbar.c: revision 1.27
usr.bin/ftp/util.c: revision 1.165
usr.bin/ftp/cmds.c: revision 1.144
usr.bin/ftp/extern.h: revision 1.84
usr.bin/ftp/fetch.c: revision 1.242
usr.bin/ftp/ftp.1: revision 1.160

s/bninary/binary/ in comment.

extract duplicate code into a function.

Check bounds when copying to destination.

Remove const where the const string ended up being overwritten.

use unsigned when doing shifts.

remove const when string gets overwritten.

ftp: exit non-zero if short http transfer when filesize is known
If a http file size is known and the fetch finishes with less bytes
transferred, exit non-zero.
Bump version to 20241129.
PR bin/54713
PR bin/58281

ftp: help improvements
Document -? as a separate mode.
Document -H HEADER in the usage.
Clarify units for -b and -x.
Consistent argument names between ftp -? and ftp(1).

ftp: order getopt Upper before lower
Consistently order options in getopt and the switch
with the upper case option before the lower case option.
This makes it easier to cross-reference with -? and ftp(1).
No functional change.
 1.24.6.1  13-Oct-2024  martin Pull up following revision(s) (requested by riastradh in ticket #970):

tests/usr.bin/Makefile: revision 1.42
usr.bin/ftp/ruserpass.c: revision 1.34
usr.bin/ftp/main.c: revision 1.130
usr.bin/ftp/ssl.c: revision 1.17
usr.bin/ftp/main.c: revision 1.131
usr.bin/ftp/ssl.c: revision 1.18
usr.bin/ftp/main.c: revision 1.132
usr.bin/ftp/ssl.c: revision 1.19
usr.bin/ftp/main.c: revision 1.133
distrib/sets/lists/tests/mi: revision 1.1342
usr.bin/ftp/ftp.1: revision 1.151
usr.bin/ftp/ftp.1: revision 1.152
usr.bin/ftp/progressbar.c: revision 1.25
usr.bin/ftp/ftp.1: revision 1.153
usr.bin/ftp/progressbar.c: revision 1.26
usr.bin/ftp/ftp.1: revision 1.155
usr.bin/ftp/ftp.1: revision 1.156
usr.bin/ftp/fetch.c: revision 1.239
usr.bin/ftp/ftp.1: revision 1.157
usr.bin/ftp/ftp.1: revision 1.158
usr.bin/ftp/ftp.1: revision 1.159
usr.bin/ftp/ftp_var.h: revision 1.87
etc/mtree/NetBSD.dist.tests: revision 1.208
usr.bin/ftp/ftp_var.h: revision 1.88
usr.bin/ftp/ftp_var.h: revision 1.89
usr.bin/ftp/cmds.c: revision 1.142
usr.bin/ftp/util.c: revision 1.168
usr.bin/ftp/cmds.c: revision 1.143
tests/usr.bin/ftp/custom_headers.sh: revision 1.1
usr.bin/ftp/ssl.c: revision 1.20
usr.bin/ftp/complete.c: revision 1.48
tests/usr.bin/ftp/Makefile: revision 1.1
tests/usr.bin/ftp/t_custom_headers.sh: revision 1.1
usr.bin/ftp/fetch.c: revision 1.240
usr.bin/ftp/fetch.c: revision 1.241
usr.bin/ftp/ftp.c: revision 1.176
usr.bin/ftp/ftp.c: revision 1.177
(all via patch)

ftp(1): wording and formatting improvements

Fix grammar issue with "Support values" reported in private mail.
Document all file transfer types in "type" and cross-reference that.
Consistency fixes in describing file transfer parameters and types.

Fix some mandoc -Tlint issues (except "useless macro: Tn").

Add -b <buflen> to specify the buffer size.

ftp: bump FTPBUFLEN from 4kB to 16kB
sourceforge.net returns a 5kB content-security-policy.
Analyzed by mlelstv@ who reports usual limits are between 4kB and 48kB.
default is now 16K

ftp: improve -b documentation

Order -b bufsize in the synopsis.

Document the actual default value.

ftp: improve units used in comments and errors
Use "KiB" instead of "K" in errors.
Clarify related comments.

pass some lint.

PR/58581: Sunil Nimmagadda: Add flag to allow specifying extra http header
fields.

ftp(1): Nix trailing whitespace in man page.
No functional change intended.

PR bin/58581: ftp(1) should allow specifying header fields in http requests
fix markup (h -> H), explain about multiple headers, fix usage (from RVP)

Don't forget the dot, use the intended macro name (I think),
and improve the wording a little. (All related to the -H option.)
ftp(1): Add test for custom HTTP header fields.

Based on a patch from Sunil Nimmagadda.

PR bin/58581: ftp(1) should allow specifying header fields in http
requests

RSS XML Feed