Commit Graph

59 Commits

Author SHA1 Message Date
lukem 76c8d5f094 * finish replacing snprintf() with sprintf(), for portability reasons.
add lots of comments about how to size up the buffers, and add extra
  checks to hopefully ensure that there won't be an overflow (unless
  someone modifies the length of the sprintf()s).
* as part of the above, slightly rework the way the `*' bar is calculated.
  also fixes a display bug when > 160 stars were needed to be printed.
  the maximum progress bar width at this time is 256.
* remove some code that checks the port that was #if 0-ed out as part of the
  ipv6 migration; it's not going to be used again.
1999-09-24 00:48:24 +00:00
lukem 700e3c1ec7 * add support for `xferbuf', which sets both `sndbuf' and `rcvbuf'
* document the above three commands
* rototill the way the sndbuf and rcvbuf work. remove resetsockbufsize()
* use the appropriate socket buffer size as the size of the buffer that
  the read()/write() loops use. speeds up things in some cases.
1999-09-22 07:18:31 +00:00
lukem 5d3667b758 replace snprintf() with strlcpy(), strlcat(), or direct assignment
where appropriate. (strlc*() are easier to port to foriegn systems).

XXX; there's still a few snprintf's in the progress meter stuff to convert
1999-09-22 03:01:53 +00:00
lukem f7ead868c0 cast 4th arg to [gs]etsockopt() to (void *), to satisfy some foriegn systems 1999-09-21 11:18:27 +00:00
lukem 375a0efb60 * change fetch_ftp() to be fully rfc 1738 compliant; if the URL contains
the an empty directory (e.g, between `some' and `path' in
  `ftp://host/some//path'), then execute `CWD ' (without a path).
  This command will probably fail on rfc 959 compliant servers, so
  issue a warning in this case and bail. [noted by cgd].
  (i wonder if the people who wrote rfc 1738 actually realised that this
  requirement appears to contravene the spec for `cwd' in rfc 959 ?)
* replace isurl() with isipv6addr(), and use appropriately. fixes
  auto-login with `classic ftp URLs' (e.g, `ftp somehost:')
* cleanup and rework some of the ipv6 stuff in parse_url()
* prevent potential coredump in fetch_ftp() when parsing `;type=X'
* KNF a few lines
* fix a couple of comments
* cleanup the man page a bit
1999-07-12 13:20:34 +00:00
itojun d1a8e792f7 add dual-stack (IPv4/v6) support. hope I broke no other part... 1999-07-02 08:07:40 +00:00
lukem e25749a582 [fear this; more ftp hacking from lukem :-]
features:
---------
* transfer rate throttling with the new `rate' command. syntax:
	rate direction [max [incr]]
  where direction is `all', `get' or `put'.
  if max is not supplied, the current settings are displayed.
  if max is supplied, then transfers in the given direction will
  be throttled to this value.
  if incr is supplied, the increment for the `on-the-fly' scaling
  will be set to that, otherwise `1024' is used.
  currently implemented for binary get, binary put, and url fetches.
  not yet supported for ascii get or put, or local file copies.
* on-the-fly scaling of the throttle based on signals:
    - SIGUSR1 raises the throttle rate by the increment for that direction
    - SIGUSR2 lowers the throttle rate by the increment for that direction
* -T dir,max[,incr] option to set rate from the command line
* `k', `m', `g' suffix support for bytecounts in the `hash', `rate',
  `rcvbuf' and `sndbuf' commands)

bug fixes and code mods:
------------------------
* fix up ftp_login() so that ruserpass() is always called, even for
  command-line url fetches.
* implement strsuftoi(), which parses a given number into a int with
  suffix support. replaces getsockbufsize()
* implement parserate(), which does the argv parsing for -T and rate
* save and restore errno in signal handlers (may not be necessary, but
  it doesn't hurt)

notes:
------
the rate command has had reasonable testing, but I'd like feedback
if it doesn't do the right thing, especially from people on slower
(i.e, modem) links.
I haven't tested the rate throttle against a http server which does
`transfer-encoding: chunked' because I couldn't find a server to
test against.
1999-06-29 10:43:16 +00:00
lukem 9ab227cabb always compile in ptransfer() (and bits of progressmeter()), so that
transfer stats are printed when verbose is enabled even if ftp is compiled
with -DNO_PROGRESS/-DSMALL. this adds back some feedback that existed
in traditional ftp that was lost when i added the progress meter.  (noticed
when ftp-ing from the -DSMALL version of ftp that's on the 1.4 boot floppy)
1999-06-26 00:17:02 +00:00
christos 102c680023 Avoid free'ing junk. It pisses off gnumalloc. 1999-06-24 23:21:02 +00:00
cgd d78b6bd31e split the "SMALL" #ifdefs into ones for NO_ABOUT, NO_EDITCOMPLETE, and
NO_PROGRESS.  -DSMALL still implies all of those.  progress meter support
isn't necessary for the smallest possible ftp client, but it adds very
little space and makes users' lives much better.  Therefore, it should
be enabled for installation media if at all possible.
1999-06-20 22:07:28 +00:00
lukem f7540e6f75 * fix gate mode to login as `user@realhost' rather than using PASSERVE;
the latter only seemed to work for TIS Gauntlet and not TIS fwtk.
  thanks to simonb@netbsd.org for testing this. fixes [bin/5556].
* if EOF (e.g, ^D) is entered at a username/password/account prompt which
  happens to use fgets(), exit the login rather than treating EOF as CR.
* don't use the comma operator where separate statements are valid
* always use snprintf to copy stuff into malloced buffers, just in case
  typos creep in and mean that the buffer ends up being overflowed
1999-06-02 02:03:57 +00:00
matthias 3f1104fb18 ftp_login would only return success for proxy connections after the last
change. Fix this by setting rval at the right place.
1999-05-20 14:08:12 +00:00
lukem eef2152360 * fix ftp_login() so that -a always logs in anonymously, even if a
.netrc entry exists for the host with a valid user. noted by
  Frederick Bruckman <fb@enteract.com> in [bin/7477]
* fix a minor memory leak associated with calling ruserpass() with
  an empty user, password, or account.
1999-05-05 16:04:58 +00:00
lukem babd00aa2c whitespace & copyright fixes 1999-03-08 03:09:08 +00:00
lukem d84dcf29f1 always run progressmeter() even if it's not the foregroundproc(), as some
calculations need to occur to prevent the calculated xfer rate from being
too fast if ftp(1) is backgrounded for a while during the xfer.
bug found by thor lancelot simon <tls@netbsd.org>.
1999-02-12 12:11:18 +00:00
lukem d00f4770d3 ftpvis(): escape LF too 1999-02-07 13:15:12 +00:00
lukem 6cc6d5d262 changes to fix [bin/6951] by Peter Simons <simons@cys.de>:
* implement ftpvis(), which \ quotes the following in the given string:
  SP, TAB, \, CR, "
* use ftpvis() in complete_ambiguous(), to escape characters in a word
  which would confuse makeargv()/slurpstring().
1999-02-07 13:14:06 +00:00
lukem 0d4c2e0d1b revert previous write->fwrite conversion in progressmeter(); stdio is bad in signal handlers, nkay? 1999-01-31 02:29:00 +00:00
lukem 0bd80459cb * -v enables verbose & progress, -V disables both
* set setvbuf(ttyout, NULL, _IOLBF, 0) and remove a bunch of fflush(ttyout).
* use fwrite() instead of write() for progressmeter (don't intermix stdio
  with non stdio ops)
1999-01-24 02:39:29 +00:00
lukem 7a3ee4352c whitespace fix 1999-01-05 22:54:49 +00:00
lukem 11154508d4 improve previous, so that display rounding is done to binary boundaries
(1024 not 1000) because the prefix determination is done that way.
tested on various boundary conditions.
1999-01-01 03:55:26 +00:00
lukem 8557ede465 add two digits of precision to the transfer rate, and always show at
least KB/s. instead of printing `5414 B/s' now print `5.41 KB/s'.
1999-01-01 02:05:05 +00:00
lukem 28007f54ca be consistent with return (foo) style 1998-12-29 14:27:59 +00:00
itohy 6d075e2860 Temporary fix of UTC -> time_t conversion:
1. changed to use timegm(3) on NetBSD and
2. supply alternative code for other Unix-like OSs
(NetBSD ftp shall be portable for some reasons :-).

This fix closes PR #6448.

NOTE: This should be fixed again if a portable UTC to time_t
conversion method is specified in some standards.
1998-11-18 07:24:25 +00:00
christos 7f1ed758a3 char -> unsigned char 1998-11-06 16:52:42 +00:00
lukem 887627831e * add transfer rate to progress meter. (suggested by hubert feyrer)
* fix up progress meter display for files once > ~20.47MB has been
  transferred.  (noted by darren reed)
* use xsignal() for SIGWINCH, so window resizes don't abort xfers on
  drainbamaged systems.
* don't assume that TIOCGWINSZ returns a non zero width.
1998-09-28 09:03:22 +00:00
lukem 688446255e * implement xsignal(); same semantics as signal() but uses sigaction
with an explicit SA_RESTART. (needed for portability)
* use xsignal() for SIGALRM and SIGINFO handlers
1998-08-08 06:46:01 +00:00
lukem b0dc919619 missed a NO_QUAD situation. be consistent in use of ifndef NO_QUAD 1998-08-08 05:06:56 +00:00
lukem 4a8ec5494d features:
* support $no_proxy, which is a comma or space separated list of
  host[:port] elements for which proxying is to be disabled.
  (asked for by cgd in [bin/5027])
* if $FTPANONPASS is defined, use that as the anon ftp password
  (instead of "`whoami`@")
* allow http URL's without a filename as long as an output file
  is specified.

other stuff:
* implement parse_url(), which breaks up a URL into its bits, and use.
* simplify url_get() and auto_fetch() to use parse_url() and to not
  modify the supplied URL or a copy of it.
* implement xmalloc() and xstrdup(); error-checked malloc()/strdup()
* add more consistency to messages, quoting strings in output as `%s'
1998-08-03 01:49:25 +00:00
lukem 2a1907a853 check EL_EDITMODE after el_source and disable editing if necessary 1998-07-29 02:46:26 +00:00
mycroft f56c79f70c const poisoning. 1998-07-26 21:47:47 +00:00
lukem 8d879385dd * send 'Connection: close' in HTTP/1.1 headers, preventing the
remove server from using a persistent connection, which speeds
  up such requests.
* support http 301 and 302 redirects
* rewrite guts of url_get() to use fparseln() et al instead of
  read(s,&p,1)...  enables each in the header to be parsed
  as necessary
* rename login to ftp_login, to remove conflict with util.h::login
* cleanup verbose messages during http proxy requests
1998-07-22 16:06:27 +00:00
thorpej 7a12770f94 Add "sndbuf" and "rcvbuf" commands for setting the socket buffer sizes,
which in turn can allow the use of larger TCP windows.  This is a work in
progress; there is not yet support for specifying global defaults or
user prefrences on a host/network basis.
1998-07-10 04:39:03 +00:00
mrg 2beab49a06 - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
1998-07-06 06:45:41 +00:00
kleink fc5d36f8e4 GLOB_QUOTE is dead; per POSIX, backslash quoting of special characters being
enabled is the default behaviour.
1998-06-19 22:58:04 +00:00
lukem 9a6e9b2ce7 some fixes & enhancements from openbsd's ftp, with extra fixes by me:
* default to passive with active fallback. $FTPMODE modifies this behaviour.
  -A forces active connection.
* support '-o outfile' for auto-fetched files. outfile can be a file,
  `-' (for stdout), or '|command' (to output each file through command).
* support '-r waittime', which retries the connection after waittime seconds
  if it fails.
* fix 'page file' when restart is non-zero.
* try all ip-addresses of a host in a http fetch (as the normal ftp fetch
  does).

XXX: a ``broken pipe'' error sometimes occurs with -o '|command';
i haven't tracked this down yet.
1998-06-04 08:28:35 +00:00
christos fad7b63434 - add <signal.h> since we are using signals.
- cast arg to is*() to unsigned char.
- don't require quad_t to exist to compile.
- adapt to the new libedit version.
1998-05-20 00:55:52 +00:00
christos 9032c78379 Don't hardcode 1900 1998-02-04 15:23:54 +00:00
lukem fa21aaa9f5 cosmetic mods to ptransfer() (which displays transfer statistics for
SIGINFO and at the end of the transfer):
* display time taken as [[x days?] hh:]mm:ss
* display ETA as [hh:]mm:ss
* print ' (stalled)' if the transfer is stalled
1998-01-20 04:39:34 +00:00
lukem 6ab4bdf006 define MAX_IN_PORT_T and use instead of USHRT_MAX. suggested by cgd@netbsd.org 1998-01-18 22:09:39 +00:00
lukem 7ee412ebee * ensure buffer for username is initialised, so ^D on username prompt
doesn't use garbage for the username.  from "Soren S. Jorvang" <soren@t.dk>
  in [bin/4559]
* use in_port_t for ports, and USHRT_MAX instead of 0xffff
  (from millert@openbsd.org)
* use `NULL' instead of `(.... *)0' where appropriate.
1998-01-18 14:23:33 +00:00
gwr 61958ba2d9 Kill the "progress bar" stuff when compiled with -DSMALL
because progressmeter() uses floats which are unwanted
when this is built under src/distrib/utils/x_ftp
(Maybe -DNO_FLOAT would be better?)
1997-12-12 23:34:56 +00:00
lukem d067f3bbd2 * in recvrequest(), ignore restart_point unless "RETR"ieving. fixes problems
where a remote completion or `mget' would confuse the client a `restart'
  had been issued beforehand. now, `restart' is remembered until an operation
  that can actually use it is invoked.
* in sendrequest(), don't reset restart_point upon entry. fixes `restart'
  for `put' operations.
* if `restart' is invoked with no arguments, print current setting instead
  of displaying a usage
* consistently use printf("%qd", (long long)restart_point) when displaying
  restart_point
* use strto[lq]() instead of atol() when parsing `mark' and `restart' values
* remove unnecessary strlen()s when result of previous snprintf() will do
* replace a few malloc()/strcpy()s with strdup()s
* use SECSPERHOUR instead of '3600'
1997-11-01 14:36:49 +00:00
christos 49e050d183 PR/4257: Jaromir Dolecek: Compensate for the libedit changes. 1997-10-14 16:31:22 +00:00
mycroft 088478fe61 If the ETA is too large to fit on the display (i.e. 100 hours or more), don't
try to display it.
Also, eliminate many extra calls to strlen().
1997-10-11 12:05:15 +00:00
lukem 8732be2e09 More cleanups from Todd Miller <Todd.Miller@courtesan.com>:
* Use an int, not "union wait".
* Move the "parsed_url" label so that the next statement is not an "else" --
  some ansi C compilers don't like it the old way (SGI's for example).
* Deal with the possibility of getlogin(2) failing.
* Don't error out if the remote server doesn't support the "MDTM" command.
1997-09-21 01:06:30 +00:00
lukem 64c651fb96 support $TMPDIR 1997-08-23 07:32:50 +00:00
lukem 2fec2a28f5 bugs fixed:
* don't interpret '-' or '|' when a local filename is determined from
  the remote name (i.e, in mget, and in get with only one argument).
  This is implemented using an extra argument to recvrequest().
  Fixes a major security hole.
* clean up memory leak when using globulize()
* clean up a couple of comments
* fix wording in TNF copyright

features added:
* support for TIS fwtk gate-ftp servers:
	* read defaults from $FTPSERVER && $FTPSERVERPORT
	* start in gate-ftp mode if invoked as 'gate-ftp'
	* toggle or set with 'gate [host [port]]'
1997-08-18 10:20:13 +00:00
lukem 609496986e fix compile on alpha:
* cast all %qd printfs to (long long) [inspired by billc@warped.net]
* replace sscanf %qd with strtoq() et al
1997-07-21 14:03:48 +00:00
lukem b9d5554d5d * use RCSID() && COPYRIGHT() macros
* cleanup for WARNS=1 (including some ugly '(void)&var' bits wrapped in
  #ifdef __GNUC__ to shut up gcc warnings WRT setjmp/longjmp)
* use strtol() instead of atoi(), and more extensively check result of
  conversion
* use u_int16_t instead of short or int for TCP port addresses
1997-07-20 09:45:35 +00:00