2013-11-17 18:03:36 +04:00
|
|
|
/*
|
|
|
|
* A dummy Socket implementation which just holds an error message.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#define DEFINE_PLUG_METHOD_MACROS
|
|
|
|
#include "tree234.h"
|
|
|
|
#include "putty.h"
|
|
|
|
#include "network.h"
|
|
|
|
|
2018-05-27 11:29:33 +03:00
|
|
|
typedef struct {
|
2013-11-17 18:03:36 +04:00
|
|
|
char *error;
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Plug *plug;
|
2018-05-27 11:29:33 +03:00
|
|
|
|
|
|
|
const Socket_vtable *sockvt;
|
|
|
|
} ErrorSocket;
|
2013-11-17 18:03:36 +04:00
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
static Plug *sk_error_plug(Socket *s, Plug *p)
|
2013-11-17 18:03:36 +04:00
|
|
|
{
|
2018-05-27 11:29:33 +03:00
|
|
|
ErrorSocket *es = FROMFIELD(s, ErrorSocket, sockvt);
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Plug *ret = es->plug;
|
2013-11-17 18:03:36 +04:00
|
|
|
if (p)
|
2018-05-27 11:29:33 +03:00
|
|
|
es->plug = p;
|
2013-11-17 18:03:36 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
static void sk_error_close(Socket *s)
|
2013-11-17 18:03:36 +04:00
|
|
|
{
|
2018-05-27 11:29:33 +03:00
|
|
|
ErrorSocket *es = FROMFIELD(s, ErrorSocket, sockvt);
|
2013-11-17 18:03:36 +04:00
|
|
|
|
2018-05-27 11:29:33 +03:00
|
|
|
sfree(es->error);
|
|
|
|
sfree(es);
|
2013-11-17 18:03:36 +04:00
|
|
|
}
|
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
static const char *sk_error_socket_error(Socket *s)
|
2013-11-17 18:03:36 +04:00
|
|
|
{
|
2018-05-27 11:29:33 +03:00
|
|
|
ErrorSocket *es = FROMFIELD(s, ErrorSocket, sockvt);
|
|
|
|
return es->error;
|
2013-11-17 18:03:36 +04:00
|
|
|
}
|
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
static char *sk_error_peer_info(Socket *s)
|
2015-05-18 15:57:45 +03:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-05-27 11:29:33 +03:00
|
|
|
static const Socket_vtable ErrorSocket_sockvt = {
|
|
|
|
sk_error_plug,
|
|
|
|
sk_error_close,
|
|
|
|
NULL /* write */,
|
|
|
|
NULL /* write_oob */,
|
|
|
|
NULL /* write_eof */,
|
|
|
|
NULL /* flush */,
|
|
|
|
NULL /* set_frozen */,
|
|
|
|
sk_error_socket_error,
|
|
|
|
sk_error_peer_info,
|
|
|
|
};
|
|
|
|
|
Get rid of lots of implicit pointer types.
All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.
All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.
A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
2018-10-04 21:10:23 +03:00
|
|
|
Socket *new_error_socket(const char *errmsg, Plug *plug)
|
2013-11-17 18:03:36 +04:00
|
|
|
{
|
2018-05-27 11:29:33 +03:00
|
|
|
ErrorSocket *es = snew(ErrorSocket);
|
|
|
|
es->sockvt = &ErrorSocket_sockvt;
|
|
|
|
es->plug = plug;
|
|
|
|
es->error = dupstr(errmsg);
|
|
|
|
return &es->sockvt;
|
2013-11-17 18:03:36 +04:00
|
|
|
}
|