Some extra int64 functions.


git-svn-id: svn://svn.tartarus.org/sgt@6778 cda61777-01e9-0310-a592-d414129be87e
Large file support for psftp and pscp on both Windows and Unix.  On Unix
we set _FILE_OFFSET_BITS to 64 on the compiler command line (via mkfiles.pl),
and on Windows we use SetFilePointer and GetFileSize to cope with 64-bit sizes
where possible.  Not tested on Win9x.


git-svn-id: svn://svn.tartarus.org/sgt@6783 cda61777-01e9-0310-a592-d414129be87e
Aha! At long last I've managed to reproduce the intermittent problem
I've been having with the cursor sometimes restoring to the wrong
place when screen(1) terminates. The offending sequence of escape
sequences goes ESC 7 (save cursor), ESC [?47h (switch to alternate
screen), ESC 7 (save cursor _again_), do some stuff, ESC 8 (restore
cursor), run screen session for a bit, ESC [?47l (return to main
screen), ESC 8 (restore cursor). The final ESC 8 is expected to
restore the cursor to where it was saved by the initial ESC 7.

Translation: the ESC 7 saved cursor state is part of the state we
must swap out when switching to the alternate screen. In other
words, we need to track _four_ cursor positions: active and saved,
on each of main and alternate screen. Previously we were tracking
only three.


git-svn-id: svn://svn.tartarus.org/sgt@6788 cda61777-01e9-0310-a592-d414129be87e
Shifts left and right by 32 were tripping a gcc warning (fatal with
-Werror, of course) about shifting by more than the range of a data
type. They only appeared in `if' statements testing sizeof(off_t),
but gcc warns even when the code is unreachable. I've removed the
conditional code (the general case should still work even on 32-bit
machines), and hacked each shift by 32 into a pair of shifts by 16.

Note that the gcc warning is not just a helpful indication that you
may be using the wrong data type; it's actually pointing out ANSI-
undefined behaviour in shifting a signed integer beyond the size of
its type.


git-svn-id: svn://svn.tartarus.org/sgt@6789 cda61777-01e9-0310-a592-d414129be87e
Er, ahem. Other half of r6788. :-/


git-svn-id: svn://svn.tartarus.org/sgt@6791 cda61777-01e9-0310-a592-d414129be87e
New piece of Windows infrastructure: winhandl.c takes Plink's
thread-based approach to stdin and stdout, wraps it in a halfway
sensible API, and makes it a globally available service across all
network tools.

There is no direct functionality enhancement from this checkin:
winplink.c now talks to the new API instead of doing it all
internally, but does nothing different as a result.

However, this should lay the groundwork for several diverse pieces
of work in future: pipe-based ProxyCommand on Windows, a serial port
back end, and (hopefully) a pipe-based means of communicating with
Pageant, which should have sensible blocking behaviour and hence
permit asynchronous agent requests and decrypt-on-demand.


git-svn-id: svn://svn.tartarus.org/sgt@6797 cda61777-01e9-0310-a592-d414129be87e
Small tweak to the new handle API: provide a `privdata' field in
each handle structure, set on initialisation and readable by an API
call.


git-svn-id: svn://svn.tartarus.org/sgt@6798 cda61777-01e9-0310-a592-d414129be87e
Bug fix: since the input thread does not wait for the event object
until _after_ its first read, we should not start by signalling that
object in order to trigger the first read. Ahem.


git-svn-id: svn://svn.tartarus.org/sgt@6799 cda61777-01e9-0310-a592-d414129be87e
Always initialise the `addresses' field of a SockAddr to NULL,
because it gets unconditionally sfree()d in sk_addr_free(). This
just bit me when running under the MSVC debugger; not sure how it
hasn't bitten anyone until now!


git-svn-id: svn://svn.tartarus.org/sgt@6800 cda61777-01e9-0310-a592-d414129be87e
Return a non-zero exit code in the event of a fatal-error SSH
session termination. `Close window only on clean exit' was not
working properly on Unix in the absence of this:
notify_remote_exit() was being called and ssh_return_exitcode was
returning zero, causing gtk_main_quit() to be called, _before_
connection_fatal() happened.


git-svn-id: svn://svn.tartarus.org/sgt@6801 cda61777-01e9-0310-a592-d414129be87e
Start using notify_remote_exit() in the Windows front end, in place
of the previous ad-hockery which depended on the return value from
select_result() and hence which will not adapt sensibly to a world
in which the primary session is something local rather than a
network connection.


git-svn-id: svn://svn.tartarus.org/sgt@6802 cda61777-01e9-0310-a592-d414129be87e
On cleanup, PSCP and PSFTP should explicitly check that the back end
is still running rather than relying on ssh_sftp_loop_iteration() to
return a bogus value.


git-svn-id: svn://svn.tartarus.org/sgt@6803 cda61777-01e9-0310-a592-d414129be87e
Cleanups to reduce dependency on Windows SFTP tools always having a
real network socket.


git-svn-id: svn://svn.tartarus.org/sgt@6804 cda61777-01e9-0310-a592-d414129be87e
Another bug fix: always set the busy flag when telling a subthread
to do something, otherwise handle_get_events will forget to tell the
front end to check for that subthread finishing. This applies even
when we're only setting `busy' to tell the subthread to terminate!


git-svn-id: svn://svn.tartarus.org/sgt@6805 cda61777-01e9-0310-a592-d414129be87e
ProxyCommand support for Windows, using the new winhandl.c API.
Seems a bit clunky when I actually try to use it - not sure why -
but I think all the actual functionality is there.


git-svn-id: svn://svn.tartarus.org/sgt@6806 cda61777-01e9-0310-a592-d414129be87e
We _can_ have handle_throttle() called on defunct handles after all,
so it should just do nothing rather than failing an assertion.


git-svn-id: svn://svn.tartarus.org/sgt@6807 cda61777-01e9-0310-a592-d414129be87e
It's critically important that the local proxy process should not
inherit _our_ ends of its I/O pipes! Otherwise, closing our copy of
those handles does not cause it to see EOF on its stdin, because
it's holding the pipe open itself.


git-svn-id: svn://svn.tartarus.org/sgt@6808 cda61777-01e9-0310-a592-d414129be87e
The `socket' function in the backends is only ever checked to see if
it's NULL. Since we already have one back end (uxpty) which doesn't
in fact talk to a network socket, and may well have more soon, I'm
replacing this TCP/IP-centric function with a nice neutral
`connected' function returning a boolean. Nothing else about its
semantics has currently changed.


git-svn-id: svn://svn.tartarus.org/sgt@6810 cda61777-01e9-0310-a592-d414129be87e
Call console_provide_logctx _before_ initialising the back end, so
that logevent() will go to stderr in -v mode even during the back
end init function.


git-svn-id: svn://svn.tartarus.org/sgt@6811 cda61777-01e9-0310-a592-d414129be87e
Remove spurious #include.


git-svn-id: svn://svn.tartarus.org/sgt@6812 cda61777-01e9-0310-a592-d414129be87e