Commit Graph

348 Commits

Author SHA1 Message Date
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