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
Grow some nasty warts on the side of winhandl.c, in preparation for
a serial port backend:
 - In order to do simultaneous reading and writing on the same
   HANDLE, you must enable overlapped access and pass an OVERLAPPED
   structure to each ReadFile and WriteFile call. This would make
   sense if it were an optional thing I could do if I wanted to do
   the reading and writing in the same thread, but making it
   mandatory even if I'm doing them in _different_ threads is just
   annoying and arbitrary.
 - Serial ports occasionally return length 0 from ReadFile, for no
   particularly good reason. Fortunately serial ports also don't
   have a real EOF condition to speak of, so ignoring EOFs is
   actually a viable response in spite of sounding utterly gross.
Hence, handle_{input,output}_new() now accept a flags parameter,
which includes a flag to enable the OVERLAPPED bureaucracy and a
flag to cause EOFs to be ignored on input handles. The current
clients of winhandl.c do not use either of these.


git-svn-id: svn://svn.tartarus.org/sgt@6813 cda61777-01e9-0310-a592-d414129be87e
Now that Local proxy type exists on both Unix and Windows, document it and
associated stuff.


git-svn-id: svn://svn.tartarus.org/sgt@6814 cda61777-01e9-0310-a592-d414129be87e
Support for Windows PuTTY connecting straight to a local serial port
in place of making a network connection. This has involved a couple
of minor infrastructure changes:
 - New dlg_label_change() function in the dialog.h interface, which
   alters the label on a control. Only used, at present, to switch
   the Host Name and Port boxes into Serial Line and Speed, which
   means that any platform not implementing serial connections (i.e.
   currently all but Windows) does not need to actually do anything
   in this function. Yet.
 - New small piece of infrastructure: cfg_launchable() determines
   whether a Config structure describes a session ready to be
   launched. This was previously determined by seeing if it had a
   non-empty host name, but it has to check the serial line as well
   so there's a centralised function for it. I haven't gone through
   all front ends and arranged for this function to be used
   everywhere it needs to be; so far I've only checked Windows.
 - Similarly, cfg_dest() returns the destination of a connection
   (host name or serial line) in a text format suitable for putting
   into messages such as `Unable to connect to %s'.


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