1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

Add lots more stub versions of standard code modules.

These are all going to be used by a test program I have in the works,
which will need to link against a lot more of the code base than any
so far. So we need a pile of new stubs.

The trickiest of these was stubs/no-network.c, which had to
conditionally define a couple of extra network functions, because
there are Windows-specific plug_closing_system_error and
plug_closing_winsock_error functions.
This commit is contained in:
Simon Tatham 2023-05-29 15:54:34 +01:00
parent 5e055a374f
commit 68d89b0e69
7 changed files with 280 additions and 0 deletions

11
stubs/no-agent.c Normal file
View File

@ -0,0 +1,11 @@
#include "putty.h"
bool agent_exists(void) { return false; }
Socket *agent_connect(Plug *plug) {
return new_error_socket_fmt(
plug, "no actual networking in this application");
}
void agent_cancel_query(agent_pending_query *pq) {}
agent_pending_query *agent_query(
strbuf *query, void **out, int *outlen,
void (*callback)(void *, void *, int), void *callback_ctx) {return NULL;}

33
stubs/no-callback.c Normal file
View File

@ -0,0 +1,33 @@
/*
* Stub version of the callback.c functions. Doesn't let anyone
* _schedule_ a callback (because that would lead them into the false
* assumption that it would actually happen later on), but permits the
* other functions without error, on the grounds that it's well
* defined what they would do if nobody had scheduled any callbacks.
*/
#include "putty.h"
void queue_idempotent_callback(struct IdempotentCallback *ic)
{
unreachable("callbacks are not supported in this application");
}
void delete_callbacks_for_context(void *ctx)
{
}
void queue_toplevel_callback(toplevel_callback_fn_t fn, void *ctx)
{
unreachable("callbacks are not supported in this application");
}
bool run_toplevel_callbacks(void)
{
return false;
}
bool toplevel_callback_pending(void)
{
return false;
}

View File

@ -6,6 +6,25 @@
#include "putty.h"
#include "ssh/pgssapi.h"
#include "ssh/gss.h"
#include "ssh/gssc.h"
const int ngsslibs = 0;
const char *const gsslibnames[1] = { "dummy" };
const struct keyvalwhere gsslibkeywords[1] = { { "dummy", 0, -1, -1 } };
struct ssh_gss_liblist *ssh_gss_setup(Conf *conf)
{
struct ssh_gss_liblist *list = snew(struct ssh_gss_liblist);
list->libraries = NULL;
list->nlibraries = 0;
return list;
}
void ssh_gss_cleanup(struct ssh_gss_liblist *list)
{
sfree(list->libraries); /* I know it's always NULL, but stay consistent */
sfree(list);
}

37
stubs/no-ldisc.c Normal file
View File

@ -0,0 +1,37 @@
#include "putty.h"
struct Ldisc_tag {
int dummy;
};
Ldisc *ldisc_create(Conf *conf, Terminal *term, Backend *backend, Seat *seat)
{
Ldisc *ldisc = snew(Ldisc);
memset(ldisc, 0, sizeof(Ldisc));
return ldisc;
}
void ldisc_configure(Ldisc *ldisc, Conf *conf)
{
}
void ldisc_free(Ldisc *ldisc)
{
sfree(ldisc);
}
void ldisc_echoedit_update(Ldisc *ldisc)
{
}
void ldisc_provide_userpass_le(Ldisc *ldisc, TermLineEditor *le)
{
}
void ldisc_check_sendok(Ldisc *ldisc)
{
}
void ldisc_send(Ldisc *ldisc, const void *vbuf, int len, bool interactive)
{
}

144
stubs/no-network.c Normal file
View File

@ -0,0 +1,144 @@
/*
* Stub version of the whole networking abstraction.
*/
#include "putty.h"
#include "network.h"
struct SockAddr {
int dummy;
};
void sk_init(void)
{
}
void sk_cleanup(void)
{
}
SockAddr *sk_namelookup(const char *host, char **canonicalname,
int address_family)
{
return snew(SockAddr);
}
SockAddr *sk_nonamelookup(const char *host)
{
return snew(SockAddr);
}
void sk_getaddr(SockAddr *addr, char *buf, int buflen)
{
strncpy(buf, "nonsense", buflen);
}
bool sk_addr_needs_port(SockAddr *addr)
{
return true;
}
bool sk_hostname_is_local(const char *name)
{
return false;
}
bool sk_address_is_local(SockAddr *addr)
{
return false;
}
bool sk_address_is_special_local(SockAddr *addr)
{
return false;
}
int sk_addrtype(SockAddr *addr)
{
return ADDRTYPE_UNSPEC;
}
void sk_addrcopy(SockAddr *addr, char *buf)
{
}
void sk_addr_free(SockAddr *addr)
{
sfree(addr);
}
SockAddr *sk_addr_dup(SockAddr *addr)
{
return snew(SockAddr);
}
Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline,
bool nodelay, bool keepalive, Plug *plug)
{
return new_error_socket_fmt(
plug, "no actual networking in this application");
}
Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
bool local_host_only, int orig_address_family)
{
return new_error_socket_fmt(
plug, "no actual networking in this application");
}
void *(sk_getxdmdata)(Socket *sock, int *lenp)
{
return NULL;
}
void plug_closing_errno(Plug *plug, int error)
{
plug_closing(plug, PLUGCLOSE_ERROR, "dummy");
}
const char *sk_addr_error(SockAddr *addr)
{
return "no actual network addresses in this application";
}
int net_service_lookup(const char *service)
{
return 0;
}
char *get_hostname(void)
{
return dupstr("dummy-hostname");
}
SockAddr *platform_get_x11_unix_address(const char *sockpath, int displaynum)
{
return snew(SockAddr);
}
SockAddr *unix_sock_addr(const char *path)
{
return snew(SockAddr);
}
SockAddr *sk_namedpipe_addr(const char *pipename)
{
return snew(SockAddr);
}
Socket *new_unix_listener(SockAddr *listenaddr, Plug *plug)
{
return new_error_socket_fmt(
plug, "no actual networking in this application");
}
Socket *platform_start_subprocess(const char *cmd, Plug *plug,
const char *prefix)
{
return new_error_socket_fmt(
plug, "no actual networking in this application");
}
#ifdef PUTTY_WINDOWS_PLATFORM_H
void plug_closing_system_error(Plug *plug, DWORD error) {}
void plug_closing_winsock_error(Plug *plug, DWORD error) {}
#endif

View File

@ -19,3 +19,8 @@ unsigned long schedule_timer(int ticks, timer_fn_t fn, void *ctx)
void expire_timer_context(void *ctx)
{
}
unsigned long timing_last_clock(void)
{
return 0;
}

31
unix/stubs/no-uxsel.c Normal file
View File

@ -0,0 +1,31 @@
/*
* Stub version of uxsel.c, for test programs.
*/
#include "putty.h"
void uxsel_init(void)
{
}
void uxsel_set(int fd, int rwx, uxsel_callback_fn callback)
{
}
void uxsel_del(int fd)
{
}
int next_fd(int *state, int *rwx)
{
return -1;
}
int first_fd(int *state, int *rwx)
{
return -1;
}
void select_result(int fd, int event)
{
}