Commit Graph

480 Commits

Author SHA1 Message Date
lukem d30bdcd79c separate out the main `data pump' loop into two: one that supports
rate limiting and one that doesn't. simplifies the code, and speeds
up the latter case a bit, at the expense of duplicating a few lines...
1999-12-11 02:02:21 +00:00
lukem 3851d504a7 Fix chunked support; probably broke after rate limiting was added.
Problem noticed/debugging assisted by giles lean <giles@nemeton.com.au>.

XXX: rate limiting with chunked xfers might not limit correctly (i.e,
the limit may be too high or too low); fixing this is non trivial,
and will probably occur if i ever rototill fetch_url()
1999-12-11 00:56:13 +00:00
lukem ef03015b86 move version into separate file to reduce recompilation after version crank. 1999-12-05 22:54:35 +00:00
lukem bcd625e612 crank version 1999-12-05 22:50:06 +00:00
lukem e36391c2c9 * remove unnecessary freeaddrinfo(res), since res0 was changed to be
freed earlier in itojun's last commit. fixes [bin/8948].
* remove `const char *reason'; it was being assigned but not used.
1999-12-05 22:49:27 +00:00
itojun 05e574f6a9 fix memory leak in fetch_url (no freeaddrinfo was there).
sync with recent KAME.
1999-12-03 06:10:01 +00:00
lukem d0090fb777 * implement xsl_init() and xsl_add(); error checking forms of sl_{init,add}()
* fix bug where the second press of <TAB> on an empty word (i.e, list
  all options) may have resulted in an strncmp() against NULL.  (detected
  by _DIAGASSERT())
1999-11-28 06:32:04 +00:00
lukem 21da08ce70 in cleanuppeer(), reset username to NULL after free()ing it.
fixes [bin/8870] by Wolfgang Rupprecht <wolfgang@wsrcc.com>
1999-11-27 01:00:06 +00:00
lukem 7047fe4a36 bump version 1999-11-26 23:26:05 +00:00
lukem f25449279d * complete_remote(): use remglob("", ...) instead of remglob(".", ...),
for listings of the current working directory; some ftp servers don't
  like `NLST .'.
  [noted by Giles Lean <giles@nemeton.com.au>]
* recvrequest(): treat remote=="" as remote==NULL when calling command().
  (to support the above change)
* support `[user@]' in `[user@]host' and `[user@]host[:][path]'.
  [based on idea (and initial code) from David Maxwell <david@fundy.ca>]
* `idle' may be invoked without any args
* reformat some comments
* reformat usage string in program and man page
* call updateremotepwd() after successful login, not after successful connect
* always call setsockopt(, IPPROTO_IP, IP_TOS, ) (et al); using #if
  defined(IPPROTO_IP) doesn't work on certain foreign systems where
  enums instead of #defines are used...
  [noted by Matthias Pfaller <leo@dachau.marco.de>]
1999-11-26 21:41:55 +00:00
lukem ecb8a0755a - implement `set rprompt'; right side version of `set prompt'. depends on
EL_RPROMPT support i added to editline(3).
- allow $FTPPROMPT and $FTPRPROMPT to override defaults for the relevant
  prompts
- move `%' formatting code from prompt() to expandbuf().
- implement `%.' and `%c', similar to the same % codes in tcsh(1)
  (functionality I added to tcsh nearly 6 years ago), except that `%.'
  always does `...trailing' and `%c' always does `/<x>trailing'.
- unknown `%foo' codes get printed as `%foo'
1999-11-12 02:50:38 +00:00
lukem 14fbd5079e - implement updateremotepwd(); update the global variable `remotepwd'
to contain the remote working directory.
- add `set prompt', a user configurable prompt. (defaults to `ftp> ').
  the following escape characters a la tcsh(1) are supported: %/, %m,
  %M, and %n.
- add global var `username'; used by prompt code
- fix a couple of minor memory leaks
- bump version
1999-11-11 02:53:02 +00:00
lukem 2ef6c64e80 whitespace nits 1999-11-11 01:19:11 +00:00
lukem b2edff6b32 - implement restarting file:/// non-proxied http:// URLs (with -R).
- fix a semicolono which stopped file:/// from working
1999-11-10 07:34:41 +00:00
lukem f8a1dcf0d2 - split the version string into product and version
- be consistent about reporting the version between:
	+ status command
	+ about:version URL fetch
	+ User-agent sent in http requests
1999-11-09 22:03:49 +00:00
lukem 3889281dc1 when using http/1.1 for unproxied http requests, send the port as a number
(e.g, `:80') instead of a name (e.g, `:http'), because the former is the
supported method that actually works...  noted by hubertf@netbsd.org
1999-11-09 07:46:22 +00:00
lukem f8233fe3ba prevent minor memory leak (unnecessary strdup) 1999-11-09 07:26:50 +00:00
lukem ed43430a7c support `about:version'. also display the version in the output of `status'. 1999-11-03 07:42:01 +00:00
lukem a5d1d869e7 hookup(): when using getservbyname() (when getaddrinfo() isn't available), if
the provided port is a valid number use that rather than trying to do
getservbyname() against it.
fixes a problem on foreign systems noted by Chuck Silvers <chuq@chuq.com>
1999-11-03 02:03:08 +00:00
lukem 4f2d3550d0 new features:
- add `usage'; displays the usage of a command.
  implemented by calling the c_handler() with argc = 0, argv = "funcname".
- add `passive auto'; does the same as $FTPMODE=auto.
- add `set [option value]'; display all options, or set an option to a value.
- add `unset option'; unset an option.
- add getoptionvalue() to retrieve an option's value, and replace a few
  global variables with calls to this.
- implement cleanuppeer(), which resets various bits of state back to
  `disconnected'. call in disconnect() and lostpeer().
- support completing on `options'.
- improve recovery after a SIGINT may have closed the connection.
  XXX: there's still a couple to fix

other stuff:
- various consistency fixes in the man page.
- ensure that the command usage strings in the code and man page match reality.
- mput/mget: check that the connection still exists before each xfer.
- minor cosmetic changes in confirm().
- set code correctly in sizecmd() and modtime()
- don't need \n in err() strings.
- change lostpeer to take an argument (rather than casting (sig_t)lostpeer
  in signal handlers)
- knf and whitespace police.
1999-10-24 12:31:36 +00:00
lukem f74df4b2ea * fix up confirm() (broke `a' and `p' in last commit)
* simplify main loop (don't need `top' variable any more)
* use a struct sockaddr_in6.sin6_addr for the result from inet_pton(),
  rather than u_char buf[16]
* add a few more comments
1999-10-13 02:47:54 +00:00
lukem 28f9cbb866 s/ARPANET/Internet/ ... 1999-10-12 08:11:59 +00:00
lukem da626f2307 a few user interface and cosmetic tweaks:
* confirm(): move from util.c to cmds.c. display mnemonic string in its prompt.
  add support for `q' (terminate current xfer), `?' (show help list)
* in various signal handlers, output a linefeed only if fromatty.
* if fgets(stdin) returned NULL (i.e, EOF), clearerr(stdin) because you don't
  want future fgets to fail. this is not done for the fgets() in the main
  command loop, since ftp will quit at that point.
* unless ftp is invoked with -a, don't retain the anonftp setting between
  hosts (`ftp somehost:' sets anonftp, but you don't want that to `stick'
  if you close that connection and open a new one).
1999-10-12 06:04:59 +00:00
lukem d5b5f0e034 * in the SIGINFO/SIGQUIT handler, print a newline before displaying
the xfer stats
* crankrate() should have a K&R decl (for consistency)
1999-10-11 12:35:42 +00:00
lukem bd5207d5ac if editing is enabled when intr() is called, print a newline. (cosmetic fix) 1999-10-11 12:34:17 +00:00
lukem 08ebd97c48 use sigjmp_buf for sigsetjmp(), instead of jmp_buf.
noted by Havard.Eidnes@runit.sintef.no.
1999-10-10 22:33:54 +00:00
lukem afb965e778 allow a second SIGINT during the "xfer aborted. waiting for remote to finish abort."
stage. if this occurs, just call lostpeer() to close the connection.  whilst this
might be considered brutal, it's also extremely handy if you're impatient or there's
lossage at the remote end.
1999-10-09 12:48:12 +00:00
lukem a53d7d57a9 * use sigsetjmp()/siglongjump() instead of setjmp()/longjmp(); the latter
don't save the signal mask on some foreign systems.
* ensure signal handlers don't use stdio and do reset errno if they
  don't exit with siglongjmp()
* use a common SIGINT handler for {send,recv}request()
1999-10-09 03:00:55 +00:00
simonb 7d7c6d9f66 Minor nit - don't append a '/' to tmpdir if it already ends in a '/'. 1999-10-07 02:05:22 +00:00
lukem ce2d63fcbf more propaganda :) 1999-10-06 08:57:46 +00:00
lukem 141ae91ed8 * fetch_url(): specifically set SIGQUIT to psummary before each xfer.
(work around editline's override)
* minor cleanup of signal handler (along the lines of similar work in
  recvrequest()). the handlers should now be reset everytime the cleanup
  handler was callled.
1999-10-05 22:12:34 +00:00
lukem c694a5290b * set SIGQUIT to psummary in each of the xfer routines. (editline seems to
override SIGQUIT when EL_SIGNAL = 1 (but we want the latter for all the
  other signal support it has).
* more fixes after previous rototill
1999-10-05 22:04:30 +00:00
lukem 781fce374d the prior change was a bit too aggressive in factoring out common code in
{send,recv}request(). completion and uploading now works again...
1999-10-05 13:44:39 +00:00
lukem 3f8b92b0b3 * factor out SIGINFO setting into a handler that is always active (but only
prints out info if bytes > 0). only set the handler if SIGINFO is defined
* hijack SIGQUIT to be the same as SIGINFO (foreign ports have this, and it's
  annoying to have SIGQUIT dump core on netbsd when it prints info on other
  systems)
* in {recv,send}request(), factor a lot of duplicated code out into a
  `cleanup' section at the end
* rework shell() a bit
1999-10-05 13:05:39 +00:00
lukem f45505380a add TNFi copyright to all files i've done more than a minor amount of work to... 1999-10-05 01:16:11 +00:00
lukem 4309cfaab3 enhancments from Marc Horowitz <marc@mit.edu> to improve connection timeouts:
* implement xsignal_restart(), which only sets the SA_RESTART flag if
  specifically requested
* xsignal() is now a wrapper to xsignal_restart(). INFO, USR1, USR2 and WINCH
  are restartable, ALRM, INT, PIPE and QUIT are not.
* improve getreply()'s timeout code to take advantage of the above.

other changes:
* improve wording of how globbing works for `classic' URLs (host:path).
  suggested by John Refling <johnr@imageworks.com> in relation to PRs
  [bin/8519] and [bin/8520]
* always compile in the `edit' command even if NO_EDITCOMPLETE defined.
  it's just a no-op in the latter case, which is more consistent to
  the users.
* always compile in about: support (i.e, remove NO_ABOUT).
  i'm entitled to some vanity in this program...
* clean up some whitespace
1999-10-05 00:54:07 +00:00
lukem 670c7ebebd restart_point is a global; no need for it here 1999-10-01 09:23:32 +00:00
lukem fcb1a22a1c If EPSV or EPRT fails, disable epsv4 for the rest of the current connection.
the disabled state can be overridden by toggling epsv4.

(I got sick of the errors about EPSV not being supported on almost
every server I connect to. This way we retain support for epsv4, but
it's not so whiny after the first failure...)
1999-10-01 08:01:12 +00:00
lukem 4c9f05c61f simple dependancy so addition of global vars to ftp_var.h is detected for main.c 1999-10-01 07:58:02 +00:00
lukem ad70c1982e prefix the global variables in ftp_var.h with GLOBAL, which defaults
to "extern" if it's not set. define GLOBAL to (empty) in main.c.
this effectively moves all the globals into main.c whilst retaining
namespace access to them in other source files.
(global vars in header files confuse foreign linkers)
1999-10-01 06:55:44 +00:00
lukem 46111773d1 * don't bother with "pathnames.h"; it contained just a single #define.
instead, include <paths.h> in the files that need it
* slightly reorg ftp_var.h
1999-10-01 06:18:32 +00:00
lukem 38100c05f4 * newer takes an optional second arg, so document this
* be a bit more explicit that the arguments to rate are in bytes
1999-10-01 05:08:31 +00:00
lukem 25790d921d * In the !NI_NUMERICHOST case (i.e, getaddrinfo() challenged systems), portnum
should be in host order. found/fixed by Matthias Pfaller <leo@dachau.marco.de>
* parse_url(): improve checking of portnum, and add an extra argument to pass
  back the parsed portnum to the caller (reduces a bit of code duplication)
* Move the KAME/WIDE copyrights after the BSD/TNFi ones. Since there was
  significantly less code added under the former, it's only fair on the latter.
1999-09-30 23:51:26 +00:00
lukem 1b3e840242 * fix initialisation of home[]
* fetch_url(): if path would be NULL, return strdup("")
1999-09-30 12:18:03 +00:00
lukem c4a3ce23de in empty(), FD_ZERO(&rmask) not (&cin). (hi christos! :)
fixes abort_remote() when __USE_SELECT is defined.
thanks to simonb@netbsd.org for reporting this bug
1999-09-30 06:35:13 +00:00
lukem 5f7fe832b6 #define BUFLEFT is always used... 1999-09-30 05:38:19 +00:00
lukem 9f5bda2e21 * consistentnly use memset(a,0,c); there were some cases of memset(a,'\0',c)
* remove explicit extern int h_errno; it's in <netdb.h>
* add <termios.h> back to util.c; it contains struct winsize on some systems
1999-09-29 00:44:01 +00:00
lukem 6c997b7af6 revert snprintf() -> sprintf(). the original idea was that sprintf() would be
more portable, except that certain systems have char *sprintf() instead of
int sprintf(). (we'll provide snprintf() on those)
1999-09-28 09:12:06 +00:00
lukem f3f34df069 don't fudge out the stalltime when calculating the ETA. this means that the
ETA might be over and will appear to drop rapidly, rather than being under
and appear not to change. the original code makes sense when you're testing
by suspending & resuming the client. however, the unfudged number is probably
better in reality, especially for slow spurty networks.

requested by ITOH Yasufumi <itohy@netbsd.org> in [bin/7977]
1999-09-28 07:54:01 +00:00
lukem 8c29ac4ade remove debugging cruft 1999-09-28 07:51:05 +00:00
lukem 256fc138f1 * add new commands:
lpage	page local files
	pdir	as dir, but through your $PAGER
	pls	as ls, but through your $PAGER
* implement docase() (a la dotrans() et al) and use appropriately, rototilling
  some duplicated code
* globulize(): modify to return a pointer to the strdup()ed result in all cases,
  and hack the code that calls it to take this into account
* replace strcpy() and strncpy() with strlcpy()
* put(), getit(): use some aptly named local vars instead of argv[...]
* delint
1999-09-28 06:47:38 +00:00
lukem 002c3f9216 * idle(): rename to idlecmd(). certain linux distributions have an incompatible
prototype for idle() in <unistd.h> (which i thought was against namespace
  and sensibility guidelines, but...)
* consistently use xsignal() instead of signal(). we get known behaviour
  in all cases (SA_RESTART), which is good for some borken foreign systems.
* remove signal.h from most files; it's unnecessary now
* fetch_url(): use `long chunksize' instead of ssize_t; it's more portable, and
  we're setting chunksize with strtol() anyway
* xsignal(): only use SA_RESTART if it exists. SunOS 4.x doesn't have it
  but has the inverse (SA_INTERRUPT). the original function i was inspired
  from had this support (lib/signal.c, W. Richard Stevens' `UNP 2nd ed Vol 1').
* remove <termios.h> from util.c; it should be unnecessary now
1999-09-27 23:32:31 +00:00
lukem 70c01ac44a * idle(): rename to idlecmd(). certain linux distributions have an incompatible
prototype for idle() in <unistd.h> (which i thought was against namespace
  and sensibility guidelines, but...)
* consistently use xsignal() instead of signal(). we get known behaviour
  in all cases (SA_RESTART), which is good for some borken foreign systems.
* remove signal.h from most files; it's unnecessary now
* fetch_url(): use `long chunksize' instead of ssize_t; it's more portable, and
  we're setting chunksize with strtol() anyway
* xsignal(): only use SA_RESTART if it exists. SunOS 4.x doesn't have it
  but has the inverse (SA_INTERRUPT). the original function i was inspired
  from had this support (lib/signal.c, W. Richard Stevens' `UNP 2nd ed Vol 1').
* remove <termios.h> from util.c; it should be unnecessary now
1999-09-27 23:09:42 +00:00
lukem 02e1aae831 remove now-unused variable left over from last commit.
(repeat after me; `test compile before commit...')
1999-09-26 14:21:50 +00:00
lukem 02387d2c93 Use tcgetpgrp(fd) instead of ioctl(fd, TIOCGPGRP, &var), because
Kimmo Suominen <kim@netbsd.org> informs me that it's more portable.
1999-09-26 14:18:01 +00:00
lukem 75e3195cad * replace ifdefs against __SVR4 and __linux__ with DIRENT_MISSING_D_NAMLEN;
it's more portable and more obvious
* remove the mkgmtime() && HAVE_TIMEGM stuff:
	a) why should netbsd have to define HAVE_TIMEGM to compile cleanly?
	b) foreign compiles of ftp should just be linked with working
	   timegm function

a more portable version of this ftp client will be released as a 3rdparty
product; no use polluting our code with half-baked attempts...
1999-09-26 02:00:12 +00:00
lukem a222db7c70 * use %lld instead of %qd to print out (long long) vars.
(slightly more portable; e.g, solaris supports this)
* remove some fluff (lint)
1999-09-24 14:28:14 +00:00
lukem 14b5ecf789 use an off_t instead of quad_t (or long #ifndef NO_QUAD) to store the
temporary restart point. (yet another portability fix...)
1999-09-24 12:52:18 +00:00
lukem ec4e414dc8 fix a couple of thinkos in my recent work:
* abort_remote(): replace borken MIN(4,BUFSIZ) with just BUFSIZ; it
  should have been MAX(4,BUFSIZ), but it's probably safe to assume that
  BUFSIZ is at least 3... (fix from simonb)
* auth_url(): use the correct variable when calculating a buffer size.
1999-09-24 06:57:37 +00:00
lukem cb8c56db8a if getsockopt() returns a buffer size of <= 0, set them to 8192.
this works around a problem in certain OS from Sun with a version < 5.6...
1999-09-24 06:14:40 +00:00
lukem e73d848293 in complete(), only copy the word if there is one.
`cd <TAB>' was triggering _DIAGASSERT(src != NULL)).
1999-09-24 05:35:09 +00:00
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 84e2c387e7 * protect more of the AF_INET6 stuff with #ifdef INET6 (for portability)
* in the main data moving loops only call the initial gettimeofday() if
  rate throttling is enabled (saves a system call per loop when not
  throttling).
1999-09-21 13:17:22 +00:00
lukem 20a4d96576 reword EPSV status line 1999-09-21 13:10:16 +00:00
lukem 2ef7f5d71d add trailing . to message 1999-09-21 12:57:51 +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 26738e38b8 only default to epsv4 if INET6 is defined 1999-09-21 10:11:56 +00:00
mycroft a502b0ee92 warn()->warnx() in a couple of places. 1999-09-14 22:49:14 +00:00
itojun a4e46e8ae8 sync with recent kAME.
- avoid s6_addr{8,16,32} which are nonstanard.
1999-09-03 04:29:57 +00:00
itojun b59b162709 ftpd(8): Copy sin6_scope_id from control connection to active data
connection destination, hoping this to help ftpd's behavior with
scoped IPv6 addresses.
I'm not sure if it is the right way, but it is the best way available to us.
LPRT or EPRT command gives no information about which interface (or scope)
to be used for new data connection.

ftp(1): On data connection establishment, warn if scoped address is used.
If peer (ftp daemon) does not handle scoped address, data connection
may not work right.

This seems to be sort of protocol spec hole, not implementation issue.
1999-09-01 05:03:41 +00:00
christos 915a67c083 The port number might have changed in the proxy case. Re-evaluate it. 1999-08-31 22:05:22 +00:00
christos 0f5eb412c3 fix proxy code. strtol() does not work very well for parsing port names. 1999-08-31 21:30:25 +00:00
christos 2cec9705c5 make ftp work again with the traditional gethostbyname/getservbyname
interfaces.
1999-08-29 22:21:57 +00:00
lukem 6d532c26d3 fetch_url() fixes:
- just display the hostname:port of the proxy url, rather than the full url.
  this prevents someone `shoulder surfing' a proxy username/password
  in $http_proxy. [suggested by perry]
- compact verbose notes for http fetchs; now displays
    (via host:port, with authorization, with proxy authorization)
  with each component being optional.
(and a couple introduced with the ipv6 mods...)
- don't override host with the canonical name; this prevented fetches from
  http/1.1 virtual hosts from working if the virtual host was a CNAME.
  [noted by bernd]
- call freeaddrinfo() if res was built with getaddrinfo()
1999-08-22 12:49:00 +00:00
lukem 8e17c17112 fix problem with www authentication: len passed to snprintf() for
auth_url() strings was 1 too small. noted by veego@
1999-08-01 12:22:23 +00:00
itojun 31055e9319 cleanup EPSV return code checking part.
remove debug fputs() left by mistake.
1999-07-20 17:52:03 +00:00
itojun a382c0c34d avoid false warnings on 22x reply code checks. previous code was too picky.
From: Wolfgang Rupprecht <wolfgang@wsrcc.com>
1999-07-17 22:39:18 +00:00
itojun 1e44889b75 implement more fallback case for EPSV. BSDI ftpd is very broken
that it returns status 228 against EPSV, where it must return status
of 229.

separate PASV and LPSV processing.

PR: 7976
1999-07-13 21:43:31 +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 940276557f add epsv4 command, which enable/disable the use of EPSV/EPRT.
this is mainly for (hypothetical) ftp server which disconnect clients
that use EPSV/EPRT.  I've never seen any ftp server like this, but
epsv4 command may be of use when such an ftp server is found.
1999-07-11 20:37:39 +00:00
christos 17e6e111b9 oops, need to declare tos. 1999-07-11 00:41:59 +00:00
christos 5d5741e3ba Kludge around non 4.4BSD systems that don't have a length field in struct
sockaddr*.
1999-07-10 20:46:42 +00:00
christos 7e3d65379b isurl does not return a pointer! 1999-07-10 19:41:15 +00:00
christos 2107d6d2da remove unused variable 1999-07-10 19:41:01 +00:00
christos c2a03912bb don't do unnecessary const castaways 1999-07-10 19:40:36 +00:00
tron 9e48344ed0 Make FTP downloads via HTTP proxy servers work again. 1999-07-06 22:11:37 +00:00
itojun 1a53711865 fix 'junk pointer free' issue. 1999-07-04 22:46:20 +00:00
itojun 2091d363f0 free dynamically allocated storage on error. 1999-07-03 05:49:57 +00:00
itojun 81ed739f62 clearify socket/connect loop. 1999-07-03 05:44:11 +00:00
itojun d1a8e792f7 add dual-stack (IPv4/v6) support. hope I broke no other part... 1999-07-02 08:07:40 +00:00
itojun 5536a65571 IPv6 support. 1999-07-02 07:59:56 +00:00
lukem a3f3aa25fd make a pointers static again (that were made automatic as part of the
xfer rate stuff, but i never completed the changes that didn't need it
set).
fixes a coredump noticed on current-users@ by Chan Yiu Wah <c5666305@hkstar.com>
1999-07-02 05:41:45 +00:00
lukem d8df707b58 s/xfer/transfer/ 1999-06-29 12:41:22 +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 3ba4ce083e don't search for trailing `;type=' in a NULL path...
fixes [bin/7800] by Mason Loring Bliss <mason@acheron.middleboro.ma.us>
1999-06-27 01:17:19 +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
christos 7d1f6b3ac3 include <signal.h> explicitly! we use sig_t extern.h, and we cannot
depend on other headers fetching it on other OS's.
1999-06-24 14:54:28 +00:00
christos 35bc148b21 rework empty() to work with both select and poll and abstract it better. 1999-06-24 14:50:56 +00:00
christos bf00d14ab4 include time.h explicitly, don't depend on other include side-effects 1999-06-24 14:48:35 +00:00
christos af43552363 remove declaration for empty; it is only used in one file and hide
it's implementation.
1999-06-24 14:46:59 +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
kleink 6d111978e7 Elaborate a bit on PAGER. 1999-06-13 20:00:03 +00:00
christos 41c6b0167f oops reversed the test. 1999-06-12 18:19:53 +00:00
christos c0c4d18130 Make this compile on linux [zoularis on linux works] 1999-06-12 18:07:34 +00:00
lukem 9bfd0a7cb6 use default pager if $PAGER="" 1999-06-11 14:12:19 +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 dedd2f772c only enable editing by default if stdin is a tty.
noticed by Onno van der Linden <onno@simplex.nl>
1999-05-17 04:26:45 +00:00
lukem 4494ebf448 parse http:// urls (and the $http_proxy variable) for [user:[pass]@]
elements, which are used for the initial authentication attempt (if
requested by the server).  in the case of $http_proxy, use the values
for proxy authentication.
1999-05-12 11:16:43 +00:00
lukem 566466ff97 update copyright 1999-05-12 11:06:00 +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 f3e5b2a6c6 clarify what uses gate-ftp mode. suggested by simonb 1999-05-04 14:16:15 +00:00
lukem 25bacdd4ea print the "xxx bare linefeeds" message after the progressmeter. noted by dan@ 1999-05-04 14:12:37 +00:00
lukem f55d4712e3 * make parsing of ftp:// urls more RFC 1738 compliant;
- the path is split on `/', and each directory is CWD-ed into separately.
      (from [standards/7484] by Alan Barrett <apb@iafrica.com>)
    - support a trailing `;type=X' suffix, where X is a,i, or d.  (d isn't
      implemented, but it is recognised)
    - the only non-compliant behaviour is that empty directories sections
      (e.g `//') aren't run as `CWD ' - as a lot of ftpds don't like that.
      Instead, treat this as a no-op.
* don't support globbing for ftp urls, since that's technically not
  RFC compliant.
* fix a couple of man-page nits
1999-04-28 13:35:40 +00:00
lukem 6b9a96fb35 revert previous (creation of /usr/bin/pftp link);
* $FTPMODE is the documented way in ftp(1) to force passive, active,
  gate-ftp, or autodetect.
* AFAIK, we haven't shipped any previous release with pftp in /usr/bin
* no link was made for gate-ftp (and i don't think that makes sense in
  /usr/bin either)
* even though the link isn't made, the support for pftp, gate-ftp, and
  the `-p' flag should remain since people may depend on having their
  own link (e.g, ~/bin/pftp -> /usr/bin/ftp) or aliases which use
  these things. it doesn't hurt to leave argv[0] checking in ftp's main().
1999-04-16 23:01:55 +00:00
mcr 67411e1a0a added LINKS= to make /usr/bin/pftp 1999-04-15 20:48:49 +00:00
lukem 82f739bcb0 when using editline, work on the correct buffer. fixes problem where blank
input lines were being added to the history buffer.
1999-03-31 02:00:42 +00:00
lukem bed9aad370 * implement -R; restart non-proxied command-line FTP xfers
* fix fetch_ftp() so that hcode parsing is not done for file:// urls
  (a } in the wrong place, and code at the wrong indent level...)
* change outfile to being a global (so it gets correctly reset)
* change parse_url to not remove leading '/' for non ftp urls.
  whilst this is not totally rfc1738 compliant, other code kinda
  assumes this is the case, and it doesn't hurt
1999-03-22 07:36:40 +00:00
christos 3853a6978b Add a few more variables that end up in registers in gcc-2.8.1 1999-03-15 08:52:17 +00:00
garbled 5b40cb5777 First round of .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages.  Many more to
come.
1999-03-15 08:22:20 +00:00
lukem 5a1118c5f9 * add url_decode() - `in-place' decode %xx escapes in a given url component
* parse_url()
-   only look for user[:pass] for an ftp url (per rfc1738)
-   strip leading /'s in an ftp url. (almost per rfc 1738)
* fetch_url()
-   decode a copy of the path and use that to build local filenames
-   send port in http Host: header (suggested by cgd@netbsd.org)
* fetch_ftp()
-   url_decode() the user, pass and path
-   fix splitting of path into dir & file (partially from [bin/7073])
-   don't bother caching the last host; it can cause problems when
    using ftp:// transfers, or when the user changes between xfers
* improve documentation of auto-fetched url arguments (especially regarding
  escape sequences in ftp:// urls)
* some whitespace & copyright updates

this should fix [bin/7073] William O Ferry <woferry@warp.wofme.com>,
as well as the metaissues raised in that PR.
1999-03-08 04:36:12 +00:00
lukem babd00aa2c whitespace & copyright fixes 1999-03-08 03:09:08 +00:00
mycroft a1c657fe56 Clean up SYNOPSIS formatting. 1999-03-07 11:29:58 +00:00
lukem 48923b69bf support restart during proxy transfers (the traditional ftp command, not the
http proxy). seems to work with my limited testing (i'm not a big user of
proxy).  bug noted by Jorgen Lundman <lundman@argonaut.com> in [bin/5948]
1999-02-19 16:29:27 +00:00
lukem b0e36dc183 during an ambiguous complete, take into account the length of the
string already input before inserting the non-ambiguous component.
bug noted by Thorsten Frueauf <frueauf@ira.uka.de> in [bin/7014]
1999-02-18 23:08:41 +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 358b69935b whitespace 1999-02-08 05:27:56 +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 b8ebb2ba4e complete ~ in local paths (noted by perry@netbsd.org) 1999-02-07 12:27:50 +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 e2352fc342 only print "Requesting..." messages if (verbose) 1999-01-25 23:17:37 +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 5051fd95cb flush ttyout in togglevar() 1999-01-24 00:51:08 +00:00
lukem 0e87f1b53d support -f, which forces a cache flush for http xfers using either
`Pragma: no-cache' (http/1.0) or `Cache-Control: no-cache' (http/1.1)
1999-01-23 15:46:24 +00:00
lukem a877181317 Fall back from passive to active if connect() fails. (from openbsd) 1999-01-05 23:33:44 +00:00
lukem 7a3ee4352c whitespace fix 1999-01-05 22:54:49 +00:00
lukem 6ae118efdb add missing braces (this is C not python...). fixes coredump on solaris 1999-01-05 00:31:20 +00:00
lukem 234fb36cc6 support http/1.1's `transfer-encoding: chunked' mode. [noted by hubertf & bad] 1999-01-01 13:26:31 +00:00
lukem 1f3ec47c0f * implement auth_url(); given a challenge, decode it, ask the user for
a response, and return the base64 encoded response. only the `Basic'
  scheme is supported.
* implement base64_enc(), which base64 encodes the given buffer
* add support for http response codes 401 "authorization required" and 407
  "proxy authorization required", using auth_url(). [requested by veego@]
1999-01-01 10:00:46 +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 974dee5975 use uname(3) to determine info to send in User-agent: header. (suggested by cgd) 1998-12-31 02:10:34 +00:00
lukem cc66a8544e * major code reorg; gut auto_fetch() and url_get() into a smaller auto_fetch(),
do_fetch() - which retrieves one file calling fetch_url() or fetch_ftp()
  as necessary.
* don't http redirect more than 5 times for a given url
* send `User-Agent: NetBSD-ftp/1.4' header in http requests. (suggested
  by Christoph Badura <bad@ora.de>)
* cleanup http return code parser, and add support for:
    - 300 `Multiple Choices' - but only if the server returns a
      preferred url in a Location: header because i'm *not* adding
      a html parser to provide the user with options.
    - 305 `Use Proxy [given in Location: header]'. (XXX: not tested)
* support http redirects to non-proxied ftp://urls. (bug discovered by
  Chris Demetriou <cgd@netbsd.org>)
* auto-login to an ftp site (using the FTP protocol) if an ftp://host/dir/
  style url is given and ftp_proxy is set. whilst this is less orthoganol
  with other ftp://host/file urls it's *much* more convenient.
1998-12-29 14:59:04 +00:00
lukem 28007f54ca be consistent with return (foo) style 1998-12-29 14:27:59 +00:00
lukem ee32f5a96b be saner about the method to determine which $proxy to use 1998-12-27 05:49:53 +00:00
christos 9ca5ef57d6 more is not less on the systems that don't have less. Make "more" the default
pager if $PAGER is not set in the name of portability.
1998-11-25 16:55:10 +00:00
explorer faade9c8e2 Send an Accept: */* header, since some sites require content negotiation.
Grr.
1998-11-22 06:52:32 +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
lukem fa954d84d1 * fix previous in a more portable manner (timegm() is not portable/standard).
use mktime(), and adjust to GMT as per code in util.c::remotemodtime()
1998-11-12 22:27:17 +00:00
itohy 638ec4fd83 HTTP uses UTC time, and changed to use timegm(3) instead of mktime(3)
for conversion of HTTP time.

XXX Unfortunately, timegm(3) is not portable (ex. SunOS 4 have, but 5 not).
1998-11-12 18:19:02 +00:00
christos 7f1ed758a3 char -> unsigned char 1998-11-06 16:52:42 +00:00
lukem da0a823fb0 * hash & progress are mutually exclusive. [noted by mrg@netbsd.org]
* in autofetch mode, don't attempt to 'cd /' on first xfer (only on
  subsequent xfers), as some ftp daemons don't permit that.
  [noted by dbj@netbsd.org].
  XXX: code could be smarter (but a lot more complicated to boot); this
  works for now.
1998-10-08 14:45:26 +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 00c10429b7 replace command(buf) with command("%s", buf) in quote1(), thus preventing
'quote' commands that contain % formats from being mis-intepreted.
noted by Lundman <lundman@argonaut.com> on current-users@netbsd.org
1998-09-01 14:25:52 +00:00
lukem 70b3ec2f32 fix handling of port on non-proxied auto-fetch ftp:// urls 1998-09-01 04:42:49 +00:00
lukem f0622bf9a4 some compilers bitch about int used when enum expected... 1998-08-08 11:23:46 +00:00
lukem 2bcc4d08b7 minor workaround for borken compilers 1998-08-08 07:51:30 +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 07a9ebee13 * fix skipping of leading / in dir, which may have resulted in
parsing junk memory (picked up whilst porting to solaris)
* remove superfluous var assignments
1998-08-08 04:40:50 +00:00
lukem 6a9c077701 pull in <sys/time.h> for utimes(), reset port to 0 in auto_fetch loop 1998-08-08 04:04:17 +00:00
lukem e4a646bf1c use utimes() instead of futimes() - the former is more portable 1998-08-08 03:33:20 +00:00
lukem 0a0b6ed3ce include <netbsd.h> for MAXHOSTNAMELEN on borken systems 1998-08-08 03:17:40 +00:00
lukem 4c105ef56e need <signal.h> for signal.... 1998-08-08 03:15:44 +00:00
lukem edcec00949 technically, you need <sys/stat.h> for struct stat .... 1998-08-08 03:06:00 +00:00
lukem 78cf64fb5d pull in <netinet/in.h> and <arpa/inet.h> for in_{addr,port}_t (more portable) 1998-08-08 03:02:55 +00:00
lukem 64fa07c111 default anon password is user@ not user@host 1998-08-08 02:58:48 +00:00
lukem efa34be454 use <limits.h> for INT_MAX (more portable) 1998-08-08 02:51:49 +00:00
lukem 69761d6f64 cleaner version of fvdl's previous fix, using xstrdup as well 1998-08-04 03:35:24 +00:00
fvdl 14f785118c Avoid using freed memory when using URLs and a proxy. 1998-08-03 19:10:29 +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 5ae8291cc6 minor grammar fix 1998-07-26 12:59:40 +00:00
lukem b521b370b5 * spell `retrieved' correctly!
* parse Last-Modified: HTTP headers for date, and change time of
  retrieved file if parsing succeeded
* support file:/// and file://localhost/ URLs
* in url_get(), re-write byte moving code to consistently use fread()
  and fwrite(), and check errors at end with ferror()
* add about:* easter-egg (#ifndef SMALL :-)
1998-07-26 12:58:16 +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
perry 41b921e7d1 Style police: "uses" is better than "utilizes", which is a horrible nelogism. 1998-07-13 17:16:22 +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
tv 063efa8267 Add the ability to work with HTTP-1.1-style virtual hosts, using the
HTTP/1.0 backwards compatible "Host:" field method.
1998-06-03 15:50:34 +00:00
lukem 881bf87781 * use CC_REFRESH_BEEP in an ambiguous complete (recently added to -ledit)
* in command completion, append a space to a definite match
* in local path completion, append a space or / to a definite match,
  depending if the path is a non-directory or directory respectively
(nothing added to remote path completion yet, until a simple sane method
 of determining if the path is a directory or not is available).
1998-06-01 14:46:11 +00:00
pk 44c785c1cd Restore `preserve' value when we no longer need the modified version. 1998-05-20 09:43:41 +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 a0a2de671b - clarify dangling else 1998-05-20 00:55:16 +00:00
christos 9160dcee94 - add <signal.h> since we are using signals.
- add <sys/time.h> since we are using utimes
- don't require quad_t to exist to compile.
1998-05-20 00:54:52 +00:00
christos 2187d01f57 - cast arg to is*() to unsigned char. 1998-05-20 00:54:26 +00:00
christos da64e19c34 - cast arg to is*() to unsigned char.
- don't require d_namlen to exist
- don't recompute the length of the file everytime around the loop.
1998-05-20 00:53:57 +00:00
christos acb3ba5670 - add <signal.h> since we are using signals.
- cast arg to is*() to unsigned char.
- don't require quad_t to exist to compile.
1998-05-20 00:52:29 +00:00
msaitoh 8e57bce5a8 fix typo. 1998-05-20 00:38:46 +00:00
kleink 650b9ca681 Need <time.h> for asctime() and localtime() prototypes. 1998-04-01 21:07:03 +00:00
christos 9032c78379 Don't hardcode 1900 1998-02-04 15:23:54 +00:00
lukem 33a9f67f94 enable el_parse for unknown commands (so editrc(5) commands can be used directly 1998-01-21 11:14:34 +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 699c57c48b correctly detect good vs bad hash mark values. (found by <enami@netbsd.org>) 1997-11-02 00:18:46 +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
mycroft b66f8512e6 Use S_IS*(), not S_IF*. 1997-10-19 19:09:05 +00:00
lukem e74da31dcc don't define WARNS=1 here 1997-10-18 15:31:20 +00:00
christos 49e050d183 PR/4257: Jaromir Dolecek: Compensate for the libedit changes. 1997-10-14 16:31:22 +00:00
christos 73d7366361 Change CFLAGS to CPPFLAGS 1997-10-14 15:09: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 a09466a728 add a space to restart message. from geoff wing in [bin/4161] 1997-09-26 15:22:46 +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 87453d32bd Fixes from Todd Miller <Todd.Miller@courtesan.com>:
* use size_t instead of int in places
* use symbolic constants when using access()
1997-09-13 09:05:52 +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 076ac8bdc3 Send \r with \n in http requests. Allow "content-length" to be missing.
From [bin/3891] by Krister Walfridsson <cato@ulysses.df.lth.se>
1997-07-20 12:49:26 +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
lukem 4a8077f211 Provide a different error message than `invalid url' when an
auto-login ftp URL is used when $ftp_proxy is defined. It now prints:
	Auto-login using ftp URLs isn't supported when using $ftp_proxy
Should solve rest of [bin/3643].

Whilst this is inconsistant with the behaviour when $ftp_proxy isn't
defined, the following constraints apply:
* it's not possible to support ftp URL auto-login when $ftp_proxy is
  defined, since it uses http not ftp, and you can't `login' to http
  servers; fudging this would require a major rewrite of ftp anyway)
* silently ignoring $ftp_proxy and not using it if an ftp auto-login
  URL is given is bad user interface design)
* mrg & others will harrass me if I remove support for autologin ftp URLs
  when $ftp_proxy isn't defined, even though it made the behaviour
  consistant whether $ftp_proxy was set or not.
1997-06-29 06:34:50 +00:00
lukem 3e92284533 * Only print the progress bar when ftp(1) is the foreground progress.
Patch from enami tsugutomo <enami@ba2.so-net.or.jp> in [bin/3735].
* Fix punctuation.
1997-06-10 21:59:58 +00:00
lukem a95a28e4d8 Don't use editing or progress bar if $TERM isn't set or is "dumb". Fixes
emacs ange-ftp. Suggested by Todd Miller <Todd.Miller@courtesan.com>,
tested by matt green <mrg@eterna.com.au>
1997-06-10 07:04:43 +00:00
lukem 8b0030a6fc Simplify NLST parsing code in complete_remote(); just basename each of
the returned names! Fixes parsing problems caused by the differences
between NLST output on BSD, Solaris, and Windows NT.
1997-05-24 16:34:30 +00:00
lukem c04e79d154 url_get(): use origline in some messages, simplifying them, and free up copy
of origline before returning. also, previous commit (fix for [bin/3643]) was
inspired by suggested fix in said PR by Alan Barrett <apb@iafrica.com>.
1997-05-23 18:54:18 +00:00
lukem 7cb8cd9611 Actually report why certain URLs are invalid, rather than just exit
with a non-zero exit code. fixes most of [bin/3643].
1997-05-23 18:42:36 +00:00
pk f6d87734a6 NULL => 0 (Arne Juul; PR#3629) 1997-05-17 19:40:47 +00:00
lukem 808ec252ad don't print -ve ETA if file size has grown. noticed by hpeyerl@netbsd.org 1997-05-12 11:41:13 +00:00
lukem 4ecb9a5a20 * cleanup parser of ftp://[user:pass@]host[:port]/[dir/][file]. should
be more robust now. fixes [bin/3520]. (missed this in previous commit msg)
* rename bad_url: to bad_ftp_url:
1997-04-21 18:45:47 +00:00
lukem d0e2ef4d67 i 1997-04-21 18:41:03 +00:00
lukem a9a78ba448 More enhancements/bugfixes (when will it end?)
* differentiate between being connected, and being logged in
* cleanup some text messages
* support username & password ftp URLs (ftp://user:pass@host/) in non-proxy
  situations; assume proxy supports it for proxy situations.
* cd to / before performing any autofetch transfers
* use strncasecmp in URL parsing. fix from <Todd.Miller@courtesan.com>
1997-04-14 09:09:15 +00:00
lukem d473547d56 * support $ftp_proxy for ftp:// transfers [bin/3245]
* add "more" & "less" as synonyms for "page"
* move editline setup code into controlediting(), and call appropriately.
  only setup setup terminal if going into interactive mode. inspired
  by Todd Miller <todd.miller@courtesan.com>
1997-04-05 03:27:32 +00:00
mrg b5b1013d11 fix buffer overrun; from bostic (via perry (via freebsd)) 1997-04-01 14:20:34 +00:00
christos 3917c3179d - Makefile cleanups 1997-03-24 21:57:01 +00:00
lukem ae07641250 Fixes from <Todd.Miller@cs.colorado.edu>, with some cleanup and reworks by me:
* only echo "Passive mode" in verbose mode; scripts that use ftp
  may get unwanted output otherwise
* disable progress bar and modification time preservation when
  retreiving to a non-regular files. fixes progress bar getting in
  way of "get file /dev/tty"
* setup el_init() et al if editing is set, not if fromatty.
  TODO: migrate this to a function, and call if editing is turned on later
	in the session. also implement edit_cleanup if editing is turned off
* call el_set() after setting SIGWINCH handler. This fixes the problem
  when suspending in a non-cbreak shell (e.g, csh) would trash your tty mode.
* reset interactive mode correctly in auto_fetch() mget mode
1997-03-16 14:24:14 +00:00
christos 067f3f2db4 SMALLFTP->SMALL; remove SMALL from Makefile 1997-03-14 01:39:31 +00:00
christos 49258416ec Deal with SMALLFTP a bit differently [by compiling complete.c] 1997-03-13 22:38:39 +00:00
lukem 3b5054739d Features:
* support remglobbing of auto_fetch arguments
* new flag - '-e'; disable editing
* "page file" == "get file |${PAGER-less}"

Bugfixes/cleanup:
* consistently use a trailing '.' on messages
* code cleanup, including buffer overrun fixes, use puts
  and putchar in places, etc (inspired by OpenBSD mods)
* disable progress bar when local-file is a pipe or '-'
* skip \r in http headers
* fix remote ftpd slash bug more elegantly (so it works with ////)
* abort_remote(): check if cout==NULL before using it. should fix [bin/3273]
* fixed up cosmetic problems when complete_remote() generated errors from the
  remote server (such as "no files found", "login with user and pass", ...)
  done by adding extra argument to remglob(), which is a pointer to an error
  buffer to put messages in rather than printing to stdout.
1997-03-13 06:23:11 +00:00
lukem 4c7551e4f0 don't display negative ETA upon SIGINFO because filesize isn't known 1997-02-01 11:26:34 +00:00
lukem 3a50014d60 [Yet Another Huge Ftp Commit - hopefully the last for a while,
barring any more little things people want added ...]

New features:
* progressmeter is now asynchronous, so "stalled" transfers can be
  detected. "- stalled -" is displayed instead of the ETA in this case.
  When the xfer resumes, the time that the xfer was stalled for is
  factored out of the ETA. It is debatable whether this is better than
  not factoring it out, but I like it this way (I.e, if it stalls for 8
  seconds and the ETA was 30 seconds, when it resumes the ETA will still
  be 30 seconds).
* verbosity can be disabled on the command line (-V), so that in auto-fetch
  mode the only lines displayed will be a description of the file, and
  the progress bar (if possible)
* if the screen is resized (and detected via the SIGWINCH signal), the
  progress bar will rescale automatically.

Bugs fixed:
* progress bar will not use the last character on the line, as this can
  cause problems on some terminals
* screen dimensions (via ioctl(TIOCWINSZ)) should use stdout not stdin
* progressmeter() used some vars before initialising them
* ^D will quit now. [fixes bin/3162]
* use hstrerror() to generate error message for host name lookup failure.
* use getcwd instead of getwd (it should have been OK, but why tempt fate?)
* auto-fetch transfers will always return a positive exit value upon failure
  or interruption, relative to the file's position in argv[].
* remote completion of / will work, without putting a leading "///".
  This is actually a bug in ftpd(1), where "NLST /" prefixes all names
  with "//", but fixing every ftpd(1) is not an option...
1997-02-01 10:44:54 +00:00
thorpej e911ec0bfe Don't try to divide by zero in progressmeter().
From Thorsten Frueauf <frueauf@ira.uka.de>, PR #3160.
1997-01-30 03:36:26 +00:00
veego 13c790f77f Add missing ; 1997-01-19 20:17:37 +00:00
lukem 7a7fa80740 New features:
* Command line editing via editline(3) library.
* Context sensitive command and file completion, including remote files.

Enhancements to auto-fetch feature:
* Support for http:// URLs using the http protocol, including proxy HTTP
  support via $htty_proxy if it's defined.
* The connection is kept open between successive files on the same host.
  (obviously, this does not count for http requests.)
* Return value of ftp is 0 on no error, or the offset in argv[] of the file
  which failed (i.e., argv[x] failed, ftp returns x).
* If the path in an ftp URL or classic format line has a trailing '/',
  cd to the path and enter interactive mode. Fixes [bin/3011], albiet
  requiring the user to help ftp in determining the operation.

Other changes:
* '-P port' works for normal ftp, and is the default for all classic style
  auto-fetch transfers and for ftp URLs that don't specify the port.
  (previously it would just work for the first xfer.)
* Some code moved into separated files along logical divisions.
* Editing and completion can be compiled out with -DSMALLFTP.
1997-01-19 14:19:02 +00:00
tls 9d225a1783 RCS ID police 1997-01-09 20:18:21 +00:00
lukem 53b51b68ea doproxy(): remove leading "proxy " from input buffer so if another() is called
and line[] is reparsed to build margc/margv, commands don't get confused.
1997-01-03 02:55:59 +00:00
lukem e699917c51 * preserve modtime if size is 0 [bin/3040, Enami Tsugutomo]
* in autofetch mode, don't retry a file if the connection failed - skip it
  and move to the next file. [bin/3051, Matt Green]
* only print error messages from SIZE or MDTM if the user used 'size' or
  'modt' (respectively). prevents extraneous warnings during normal transfers
  when connected to a site which doesn't support these (behaviour prior to
  last commit), but still allows error feedback to specific user requests
  for this info (which the last commit broke).
* 'account': only accept one optional argument
* if invoked as pftp, default to passive mode on (from FreeBSD)
* remove leading '0 ' in progress bar - looked ugly
* use warn instead of perror
* use strncpy when src isn't known to have safe length
* remglob(): use mkstemp() to prevent symlink games, and don't override
  _PATH_TMP, use it as the prefix to the temp file
1996-12-29 04:05:29 +00:00
christos 764c65979e - make sure that the reply string is null-terminated, and copy only up to
the initialized copy of the source string, since the source string is not
  null terminated at this point.
1996-12-25 16:02:06 +00:00
christos 942194d9f4 - Don't print the '500 command not understood' reply for the SIZE and
MDTM commands which are not supported by all ftp servers, unless we
  are in debugging mode.
1996-12-25 16:00:38 +00:00
lukem dd6f8f2061 'b' == bits not bytes. for all prefixes >= 'K', explicitly specify 'B'
afterwards. don't print anything for a pure byte count. rework ETA display
as well.
1996-12-06 04:33:45 +00:00
lukem 2bee2a678e * note that nlist and ls and equivalent
* fix up optional argument descriptions for dir, ls, nlist, and user.
1996-12-06 02:28:13 +00:00
lukem b6df1b3d2d functionality mods:
* implement 'progress bar/meter' (inspired by ncftp). use 'progress' to
  toggle on. it will display current file size to 5 digits, automatically
  determining suffix (up to 16384 P (petabytes) == 2^64).
* 'ls' now uses NLST (unadorned listing), a la older ftp clients. 'dir'
  still does LIST (long listing). idea from John Nemeth <jnemeth@cue.bc.ca>

bug fixes:
* return first line of reply in reply_string[] from getreply(), instead
  of last line. This fixes [bin/741] (parsing of SYST), and also means
  that SIZE and MDTM messages will be parsed correctly if they're longer
  than 1 line.
* parse URL-style auto-ftps that have no filename correctly
  (e.g, ftp://host, ftp://host/, ftp://host/dir/). pointed out by
  Jaromir Dolecek <dolecek@saruman.ics.muni.cz>
* pass the correct size array in 2nd arg of utimes() when setting the
  modification time
1996-12-06 02:06:46 +00:00
lukem 8ef5f80460 More features, some of which were inspired by changes that
friedman@gnu.ai.mit.edu (Noah Friedman) made to his modified ftp:
- implement "lpwd" - local pwd
- implement "preserve" - toggle preserving of file modification
  times on retrieved files
- allow for explicit "on" or "off" arg to toggle commands
- "exit" synonym for "quit", "msend" synonym for "mput"
- in confirmation mode, allow 'a' (yes to rest of current command),
  and 'p' (turn off prompt mode, as if 'prompt off' was done,
  effective immediately)
- "modtime" returns time formatted as localtime, not GMT

Bug fixes:
- check for extraneous args on commands
- cleanup const usage, line formatting
- create 0 length temporary file in remglob() to prevent symlink games
  (from OpenBSD)
- check length of filename of ~/.netrc (from OpenBSD)
1996-11-28 03:12:28 +00:00
fvdl 7970a0483a Correct the connecthelp info. This is really ftp, not tftp. 1996-11-25 09:53:50 +00:00